summaryrefslogtreecommitdiff
path: root/testrepository/tests
diff options
context:
space:
mode:
authorRobert Collins <robertc@robertcollins.net>2013-04-08 00:05:05 +1200
committerRobert Collins <robertc@robertcollins.net>2013-04-08 00:05:05 +1200
commitc64ec4fe698cc337a415baafe562f6d45d7e78f9 (patch)
treefd2d7d8e168b38de6715e416add0305106158801 /testrepository/tests
parent15124cb50d441bd007b10a5361d53b938f47ae50 (diff)
downloadtestrepository-c64ec4fe698cc337a415baafe562f6d45d7e78f9.tar.gz
Add test for --subunit support - the UI was previously only loosely tested.
Diffstat (limited to 'testrepository/tests')
-rw-r--r--testrepository/tests/ui/test_cli.py16
1 files changed, 14 insertions, 2 deletions
diff --git a/testrepository/tests/ui/test_cli.py b/testrepository/tests/ui/test_cli.py
index eaa4193..01ac8cc 100644
--- a/testrepository/tests/ui/test_cli.py
+++ b/testrepository/tests/ui/test_cli.py
@@ -320,12 +320,16 @@ class TestCLITestResult(TestCase):
except ZeroDivisionError:
return sys.exc_info()
- def make_result(self, stream=None):
+ def make_result(self, stream=None, argv=None):
if stream is None:
stream = BytesIO()
- argv = []
+ argv = argv or []
ui = cli.UI(argv, None, stream, None)
cmd = commands.Command(ui)
+ cmd.options = [
+ optparse.Option("--subunit", action="store_true",
+ default=False, help="Display results in subunit format."),
+ ]
ui.set_command(cmd)
return ui.make_result(lambda: None, StubTestCommand())
@@ -393,3 +397,11 @@ class TestCLITestResult(TestCase):
self.assertThat(
stream.getvalue().decode('utf8'),
DocTestMatches(pattern, doctest.ELLIPSIS))
+
+ def test_subunit_output(self):
+ bytestream = BytesIO()
+ stream = TextIOWrapper(bytestream, 'utf8', line_buffering=True)
+ result = self.make_result(stream, argv=['--subunit'])[0]
+ result.startTestRun()
+ result.stopTestRun()
+ self.assertEqual(b'', bytestream.getvalue())