From 714903c2bb135fb0bf71f684c7e42d76250aa65a Mon Sep 17 00:00:00 2001 From: Robert Collins Date: Wed, 13 Mar 2013 04:30:06 +1300 Subject: * ``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) --- python/subunit/run.py | 7 +++++++ 1 file changed, 7 insertions(+) (limited to 'python') 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) -- cgit v1.2.1