diff options
| author | Robert Collins <robertc@robertcollins.net> | 2013-03-13 04:30:06 +1300 |
|---|---|---|
| committer | Robert Collins <robertc@robertcollins.net> | 2013-03-13 04:30:06 +1300 |
| commit | 205803cd9aa68bae23d284593cbd5ec3135ac5e2 (patch) | |
| tree | 4cdf83c91df15b7832d632017008ac3b0f596721 /python | |
| parent | 2c8480561713e524dafa3cbf22156f048f1de585 (diff) | |
| download | subunit-git-205803cd9aa68bae23d284593cbd5ec3135ac5e2.tar.gz | |
* ``subunit.run`` now replaces sys.stdout to ensure that stdout is unbuffered
- without this pdb output is not reliably visible when stdout is a pipe
as it usually is. (Robert Collins)
Diffstat (limited to 'python')
| -rwxr-xr-x | python/subunit/run.py | 7 |
1 files changed, 7 insertions, 0 deletions
diff --git a/python/subunit/run.py b/python/subunit/run.py index d0a4a91..b78bf32 100755 --- a/python/subunit/run.py +++ b/python/subunit/run.py @@ -20,6 +20,7 @@ $ python -m subunit.run mylib.tests.test_suite """ +import io import os import sys @@ -109,5 +110,11 @@ if __name__ == '__main__': # on non-ttys. stream = get_default_formatter() runner = SubunitTestRunner + # Patch stdout to be unbuffered, so that pdb works well. + binstdout = io.open(sys.stdout.fileno(), 'wb', 0) + if sys.version_info[0] > 2: + sys.stdout = io.TextIOWrapper(binstdout, encoding=sys.stdout.encoding) + else: + sys.stdout = binstdout SubunitTestProgram(module=None, argv=sys.argv, testRunner=runner, stdout=sys.stdout) |
