Skip to content

try to fix error where modules writing directly to sys.stdout.buffer blow up #276

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 18 additions & 1 deletion tox.ini
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,24 @@ commands =
python -m xmlrunner discover -p test_xmlrunner_output
codecov -e TOXENV
-coveralls
passenv = CI TRAVIS_BUILD_ID TRAVIS TRAVIS_BRANCH TRAVIS_JOB_NUMBER TRAVIS_PULL_REQUEST TRAVIS_JOB_ID TRAVIS_REPO_SLUG TRAVIS_COMMIT CODECOV_TOKEN COVERALLS_REPO_TOKEN GITHUB_ACTION GITHUB_HEAD_REF GITHUB_REF GITHUB_REPOSITORY GITHUB_RUN_ID GITHUB_SHA
passenv =
CI
TRAVIS_BUILD_ID
TRAVIS
TRAVIS_BRANCH
TRAVIS_JOB_NUMBER
TRAVIS_PULL_REQUEST
TRAVIS_JOB_ID
TRAVIS_REPO_SLUG
TRAVIS_COMMIT
CODECOV_TOKEN
COVERALLS_REPO_TOKEN
GITHUB_ACTION
GITHUB_HEAD_REF
GITHUB_REF
GITHUB_REPOSITORY
GITHUB_RUN_ID
GITHUB_SHA


[testenv:pytest]
Expand Down
4 changes: 4 additions & 0 deletions xmlrunner/result.py
Original file line number Diff line number Diff line change
Expand Up @@ -291,6 +291,10 @@ def _setupStdout(self):
sys.stdout = _DuplicateWriter(sys.stdout, self._stdout_capture)
self.__stderr_saved = sys.stderr
sys.stderr = _DuplicateWriter(sys.stderr, self._stderr_capture)
# avoid issues where modules like python-subunit try to write directly to sys.stdout.buffer
# when there is no buffer
if not hasattr(sys.stdout, 'buffer'):
sys.stdout.buffer = _DuplicateWriter(sys.stdout, self._stdout_capture)

def _restoreStdout(self):
"""
Expand Down