Skip to content

πŸ› JsonParser opens the report without an encodingΒ #2014

Description

@chrisjsewell

ub_test_reports/jsonparser.py:42 (39b73156) opens the report with open(self.json_path) β€” no encoding. On Windows that decodes with the locale encoding (cp1252 by default), so a JSON report carrying a non-ASCII character outside cp1252 β€” a test name with an emoji, a message with CJK text β€” fails with UnicodeDecodeError, or decodes to the wrong characters where cp1252 happens to accept the bytes. tox-envreport / the JSON shape the parser documents is UTF-8.

Pre-existing (the line moved unchanged from sphinx_test_reports in #2009); reviewer B of that PR measured that all 13 fixtures are pure ASCII, so the suite cannot see it. Fix: open(self.json_path, encoding="utf-8"), plus one fixture (or a tmp_path report) with a non-cp1252 character, red-first on a PYTHONUTF8=0 run or by monkeypatching locale.getpreferredencoding. Check junitparser.py while there: lxml parses bytes and honours the XML declaration, so it is not affected, but say so in the test.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugpkg: ub-test-reportsConcerns the ub-test-reports package (packages/ub-test-reports): the Sphinx-free test-reports core

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions