Fix tests with testtools 1.2.0 and above.

Import errors don't break execution or listing now in testtools, so to
test execution breaking we have to be a little bit more direct.
This commit is contained in:
Robert Collins 2014-11-18 21:12:38 +13:00
parent 52dad0f4f5
commit 7c203ff76e
2 changed files with 13 additions and 2 deletions

6
NEWS
View File

@ -5,6 +5,12 @@ subunit release notes
NEXT (In development)
---------------------
BUGFIXES
~~~~~~~~
* Tests have been fixed with testtools 1.2.0 and above.
(Robert Collins)
0.0.21
------

View File

@ -80,9 +80,14 @@ class TestSubunitTestRunner(TestCase):
self.fail("SystemExit raised")
self.assertThat(bytestream.getvalue(), StartsWith(_b('\xb3')))
class ExitingTest(TestCase):
def test_exit(self):
raise SystemExit(0)
def test_exits_nonzero_when_execution_errors(self):
bytestream = io.BytesIO()
stream = io.TextIOWrapper(bytestream, encoding="utf8")
exc = self.assertRaises(Exception, run.main,
argv=["progName", "subunit.tests.test_run.TestSubunitTestRunner.MissingTest"],
exc = self.assertRaises(SystemExit, run.main,
argv=["progName", "subunit.tests.test_run.TestSubunitTestRunner.ExitingTest"],
stdout=stream)
self.assertEqual(0, exc.args[0])