testmycode / tmc-langs

TMC language support framework
2 stars 17 forks source link

Use default system encoding when reading test result JSON-file (Python3) #104

Closed jesseanttila-cai closed 4 years ago

jesseanttila-cai commented 4 years ago

The Python 3 test runner uses .tmc_test_results.json to report its results, the contents of which are written in the default system encoding. The corresponding parser on the Java side expects the content to be utf-8 encoded, which causes a parsing error on Windows systems when non-ASCII characters appear in the test results.

This patch solves the issue by reading the test result file using the default system encoding, which should match the one it was written in. The alternative solution of always having the Python 3 test runner write its results using the utf-8 encoding would require all exercises to be updated.

Finally, this solution could be made more robust by using an encoding detection library to find a compatible encoding, although that approach will result in false matches for some bytestrings.

Redande commented 4 years ago

Maven checkstyle failed due to row 54 in the modified file. Could you indent the row correctly please? You can run mvn checkstyle:check in terminal to see possible checkstyle errors.

Travis also failed due to log length exceeding the limit. There's been a fix to not log as much output, which was merged to master. Could you rebase this branch to include that fix so that Travis passes please?

Otherwise this looks good, and sounds like a good fix to the parsing error. Thank you for offering this fix!