diff options
| author | Robert Collins <robertc@robertcollins.net> | 2013-03-06 23:16:03 +1300 |
|---|---|---|
| committer | Robert Collins <robertc@robertcollins.net> | 2013-03-06 23:16:03 +1300 |
| commit | 2c8480561713e524dafa3cbf22156f048f1de585 (patch) | |
| tree | 654c2e1b3161b1ec7150bea04e01688a612a3c6a /python/subunit/run.py | |
| parent | 36de6f4f7542b10f93061b65bcf7464a74cb9ddc (diff) | |
| download | subunit-git-2c8480561713e524dafa3cbf22156f048f1de585.tar.gz | |
Fixes from getting testrepository running with v2.
Diffstat (limited to 'python/subunit/run.py')
| -rwxr-xr-x | python/subunit/run.py | 23 |
1 files changed, 19 insertions, 4 deletions
diff --git a/python/subunit/run.py b/python/subunit/run.py index 612d7ea..d0a4a91 100755 --- a/python/subunit/run.py +++ b/python/subunit/run.py @@ -50,9 +50,7 @@ class SubunitTestRunner(object): def run(self, test): "Run the given test case or test suite." - result = StreamResultToBytes(self.stream) - for case in iterate_tests(test): - result.status(test_id=case.id(), test_status='exists') + result = self._list(test) result = ExtendedToStreamDecorator(result) result = AutoTimingTestResultDecorator(result) if self.failfast is not None: @@ -64,6 +62,24 @@ class SubunitTestRunner(object): result.stopTestRun() return result + def list(self, test): + "List the test." + self._list(test) + + def _list(self, test): + try: + fileno = self.stream.fileno() + except: + fileno = None + if fileno is not None: + stream = os.fdopen(fileno, 'wb', 0) + else: + stream = self.stream + result = StreamResultToBytes(stream) + for case in iterate_tests(test): + result.status(test_id=case.id(), test_status='exists') + return result + class SubunitTestProgram(TestProgram): @@ -91,7 +107,6 @@ class SubunitTestProgram(TestProgram): if __name__ == '__main__': # Disable the default buffering, for Python 2.x where pdb doesn't do it # on non-ttys. - sys.stdout = os.fdopen(sys.stdout.fileno(), 'ab', 0) stream = get_default_formatter() runner = SubunitTestRunner SubunitTestProgram(module=None, argv=sys.argv, testRunner=runner, |
