summaryrefslogtreecommitdiff
path: root/python
diff options
context:
space:
mode:
authorMartin <gzlist@googlemail.com>2011-04-27 02:25:24 +0100
committerMartin <gzlist@googlemail.com>2011-04-27 02:25:24 +0100
commit5a28b540845585f07ec1f10b96305c77f63104dd (patch)
treed85962660bbb286383d4e91431cab2ddfab07242 /python
parent4b6abb5335d793f842abaab3121276c7737481a0 (diff)
downloadsubunit-git-5a28b540845585f07ec1f10b96305c77f63104dd.tar.gz
Hack ExecTestCase and its tests to sort-of be portable fixing the remaing spew
Diffstat (limited to 'python')
-rw-r--r--python/subunit/__init__.py8
-rwxr-xr-xpython/subunit/tests/sample-script.py3
2 files changed, 9 insertions, 2 deletions
diff --git a/python/subunit/__init__.py b/python/subunit/__init__.py
index a7048d3..82864f7 100644
--- a/python/subunit/__init__.py
+++ b/python/subunit/__init__.py
@@ -817,6 +817,8 @@ class ExecTestCase(unittest.TestCase):
"""
unittest.TestCase.__init__(self, methodName)
testMethod = getattr(self, methodName)
+ # GZ 2011-04-25: Embedding shell commands in docstrings is fragile and
+ # and may break if the module directory contains spaces
self.script = join_dir(sys.modules[self.__class__.__module__].__file__,
testMethod.__doc__)
@@ -833,8 +835,10 @@ class ExecTestCase(unittest.TestCase):
def _run(self, result):
protocol = TestProtocolServer(result)
- output = subprocess.Popen(self.script, shell=True,
- stdout=subprocess.PIPE).communicate()[0]
+ process = subprocess.Popen(self.script, shell=True,
+ stdout=subprocess.PIPE)
+ _make_stream_binary(process.stdout)
+ output = process.communicate()[0]
protocol.readFrom(BytesIO(output))
diff --git a/python/subunit/tests/sample-script.py b/python/subunit/tests/sample-script.py
index 0ee019a..618e495 100755
--- a/python/subunit/tests/sample-script.py
+++ b/python/subunit/tests/sample-script.py
@@ -1,5 +1,8 @@
#!/usr/bin/env python
import sys
+if sys.platform == "win32":
+ import msvcrt, os
+ msvcrt.setmode(sys.stdout.fileno(), os.O_BINARY)
if len(sys.argv) == 2:
# subunit.tests.test_test_protocol.TestExecTestCase.test_sample_method_args
# uses this code path to be sure that the arguments were passed to