From 32c509a08cf007134fa154649c05d6fb0761ab55 Mon Sep 17 00:00:00 2001 From: Robert Collins Date: Sat, 18 Jul 2009 13:43:05 +1000 Subject: Support arguments in ExecTestCase. --- python/subunit/__init__.py | 4 ++-- python/subunit/tests/sample-script.py | 4 ++++ python/subunit/tests/test_test_protocol.py | 9 +++++++++ 3 files changed, 15 insertions(+), 2 deletions(-) (limited to 'python/subunit') diff --git a/python/subunit/__init__.py b/python/subunit/__init__.py index 7d800a8..fb6c83e 100644 --- a/python/subunit/__init__.py +++ b/python/subunit/__init__.py @@ -432,8 +432,8 @@ class ExecTestCase(unittest.TestCase): def _run(self, result): protocol = TestProtocolServer(result) - output = subprocess.Popen([self.script], - stdout=subprocess.PIPE).communicate()[0] + output = subprocess.Popen(self.script, shell=True, + stdout=subprocess.PIPE).communicate()[0] protocol.readFrom(StringIO(output)) diff --git a/python/subunit/tests/sample-script.py b/python/subunit/tests/sample-script.py index 223d2f5..33e5cb2 100755 --- a/python/subunit/tests/sample-script.py +++ b/python/subunit/tests/sample-script.py @@ -1,5 +1,9 @@ #!/usr/bin/env python import sys +if len(sys.argv) == 2: + print "test fail" + print "error fail" + sys.exit(0) print "test old mcdonald" print "success old mcdonald" print "test bing crosby" diff --git a/python/subunit/tests/test_test_protocol.py b/python/subunit/tests/test_test_protocol.py index 80f91e1..ead0ac6 100644 --- a/python/subunit/tests/test_test_protocol.py +++ b/python/subunit/tests/test_test_protocol.py @@ -823,12 +823,21 @@ class TestExecTestCase(unittest.TestCase): # the sample script runs three tests, one each # that fails, errors and succeeds + def test_sample_method_args(self): + """sample-script.py foo""" + # sample that will run just one test. def test_construct(self): test = self.SampleExecTestCase("test_sample_method") self.assertEqual(test.script, subunit.join_dir(__file__, 'sample-script.py')) + def test_args(self): + result = unittest.TestResult() + test = self.SampleExecTestCase("test_sample_method_args") + test.run(result) + self.assertEqual(1, result.testsRun) + def test_run(self): runner = MockTestProtocolServerClient() test = self.SampleExecTestCase("test_sample_method") -- cgit v1.2.1 From 3549290ea1c272eaaae6feb0130db20f1c797442 Mon Sep 17 00:00:00 2001 From: Robert Collins Date: Sun, 19 Jul 2009 14:07:51 +1000 Subject: Add docs to the sample-script explaining why it has an argv check. --- python/subunit/tests/sample-script.py | 3 +++ 1 file changed, 3 insertions(+) (limited to 'python/subunit') diff --git a/python/subunit/tests/sample-script.py b/python/subunit/tests/sample-script.py index 33e5cb2..0ee019a 100755 --- a/python/subunit/tests/sample-script.py +++ b/python/subunit/tests/sample-script.py @@ -1,6 +1,9 @@ #!/usr/bin/env python import sys 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 + # sample-script.py print "test fail" print "error fail" sys.exit(0) -- cgit v1.2.1