diff options
| author | Robert Collins <robertc@robertcollins.net> | 2011-05-02 10:36:15 +1200 |
|---|---|---|
| committer | Robert Collins <robertc@robertcollins.net> | 2011-05-02 10:36:15 +1200 |
| commit | 8301c8f3024496f57a393a83a153c73142b445ae (patch) | |
| tree | e7a9b25aaa230053b1640ae95cd1f213fccb4070 /python | |
| parent | 22df1b70c04ec46167e17945bab835cf5a4d95f9 (diff) | |
| parent | 43cc336e58f81cd4fdb1692233980110bbc80542 (diff) | |
| download | subunit-git-8301c8f3024496f57a393a83a153c73142b445ae.tar.gz | |
Martins fix for failures on windows.
Diffstat (limited to 'python')
| -rw-r--r-- | python/subunit/__init__.py | 6 | ||||
| -rwxr-xr-x | python/subunit/tests/sample-script.py | 3 | ||||
| -rw-r--r-- | python/subunit/tests/test_test_protocol.py | 17 |
3 files changed, 19 insertions, 7 deletions
diff --git a/python/subunit/__init__.py b/python/subunit/__init__.py index e92eb26..807b605 100644 --- a/python/subunit/__init__.py +++ b/python/subunit/__init__.py @@ -833,8 +833,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 diff --git a/python/subunit/tests/test_test_protocol.py b/python/subunit/tests/test_test_protocol.py index 7ec7758..939b642 100644 --- a/python/subunit/tests/test_test_protocol.py +++ b/python/subunit/tests/test_test_protocol.py @@ -18,6 +18,7 @@ import datetime import unittest import os +from testtools import skipIf, TestCase from testtools.compat import _b, _u, BytesIO, StringIO from testtools.content import Content, TracebackContent from testtools.content_type import ContentType @@ -107,7 +108,8 @@ class TestTestProtocolServerStartTest(unittest.TestCase): def setUp(self): self.client = Python26TestResult() - self.protocol = subunit.TestProtocolServer(self.client) + self.stream = BytesIO() + self.protocol = subunit.TestProtocolServer(self.client, self.stream) def test_start_test(self): self.protocol.lineReceived(_b("test old mcdonald\n")) @@ -125,8 +127,10 @@ class TestTestProtocolServerStartTest(unittest.TestCase): [('startTest', subunit.RemotedTestCase("old mcdonald"))]) def test_indented_test_colon_ignored(self): - self.protocol.lineReceived(_b(" test: old mcdonald\n")) + ignored_line = _b(" test: old mcdonald\n") + self.protocol.lineReceived(ignored_line) self.assertEqual([], self.client._events) + self.assertEqual(self.stream.getvalue(), ignored_line) def test_start_testing_colon(self): self.protocol.lineReceived(_b("testing: old mcdonald\n")) @@ -909,7 +913,8 @@ class TestExecTestCase(unittest.TestCase): def test_join_dir(self): sibling = subunit.join_dir(__file__, 'foo') - expected = '%s/foo' % (os.path.split(__file__)[0],) + filedir = os.path.abspath(os.path.dirname(__file__)) + expected = os.path.join(filedir, 'foo') self.assertEqual(sibling, expected) @@ -919,7 +924,7 @@ class DoExecTestCase(subunit.ExecTestCase): """sample-two-script.py""" -class TestIsolatedTestCase(unittest.TestCase): +class TestIsolatedTestCase(TestCase): class SampleIsolatedTestCase(subunit.IsolatedTestCase): @@ -940,6 +945,7 @@ class TestIsolatedTestCase(unittest.TestCase): def test_construct(self): self.SampleIsolatedTestCase("test_sets_global_state") + @skipIf(os.name != "posix", "Need a posix system for forking tests") def test_run(self): result = unittest.TestResult() test = self.SampleIsolatedTestCase("test_sets_global_state") @@ -955,7 +961,7 @@ class TestIsolatedTestCase(unittest.TestCase): #test.debug() -class TestIsolatedTestSuite(unittest.TestCase): +class TestIsolatedTestSuite(TestCase): class SampleTestToIsolate(unittest.TestCase): @@ -976,6 +982,7 @@ class TestIsolatedTestSuite(unittest.TestCase): def test_construct(self): subunit.IsolatedTestSuite() + @skipIf(os.name != "posix", "Need a posix system for forking tests") def test_run(self): result = unittest.TestResult() suite = subunit.IsolatedTestSuite() |
