summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRobert Collins <robertc@robertcollins.net>2014-11-18 21:57:57 +1300
committerRobert Collins <robertc@robertcollins.net>2014-11-18 21:57:57 +1300
commiteb1f9f664dd96e7fb93a359d1bec99b92fd0ec1f (patch)
tree0830c5dd026ff896c02a0b5f71bdd1505176e81e
parent71a7491a034459de6ebc6a9c211f6b2bd05345ff (diff)
downloadsubunit-eb1f9f664dd96e7fb93a359d1bec99b92fd0ec1f.tar.gz
Improve showing of import errors in the Python runner.
This depends on testtools 1.4.0 to get the improved behaviour.
-rw-r--r--NEWS6
-rwxr-xr-xpython/subunit/run.py6
-rw-r--r--python/subunit/tests/test_run.py12
3 files changed, 23 insertions, 1 deletions
diff --git a/NEWS b/NEWS
index 60028d9..ed281ac 100644
--- a/NEWS
+++ b/NEWS
@@ -11,6 +11,12 @@ BUGFIXES
* Tests have been fixed with testtools 1.2.0 and above.
(Robert Collins)
+IMPROVEMENTS
+~~~~~~~~~~~~
+
+* With testtools 1.4.0 and above import errors are now
+ shown in detail by ``subunit.run``. (Robert Collins)
+
0.0.21
------
diff --git a/python/subunit/run.py b/python/subunit/run.py
index cf9cc01..5bf1db2 100755
--- a/python/subunit/run.py
+++ b/python/subunit/run.py
@@ -70,9 +70,13 @@ class SubunitTestRunner(object):
result.stopTestRun()
return result
- def list(self, test):
+ def list(self, test, loader=None):
"List the test."
result, errors = self._list(test)
+ if loader is not None:
+ # We were called with the updated API by testtools.run, so look for
+ # errors on the loader, not the test list result.
+ errors = loader.errors
if errors:
failed_descr = '\n'.join(errors).encode('utf8')
result.status(file_name="import errors", runnable=False,
diff --git a/python/subunit/tests/test_run.py b/python/subunit/tests/test_run.py
index de9b094..3339a82 100644
--- a/python/subunit/tests/test_run.py
+++ b/python/subunit/tests/test_run.py
@@ -65,6 +65,18 @@ class TestSubunitTestRunner(TestCase):
exc = self.assertRaises(SystemExit, runner.list, None)
self.assertEqual((2,), exc.args)
+ def test_list_includes_loader_errors(self):
+ bytestream = io.BytesIO()
+ runner = SubunitTestRunner(stream=bytestream)
+ def list_test(test):
+ return [], []
+ class Loader(object):
+ errors = ['failed import']
+ loader = Loader()
+ self.patch(run, 'list_test', list_test)
+ exc = self.assertRaises(SystemExit, runner.list, None, loader=loader)
+ self.assertEqual((2,), exc.args)
+
class FailingTest(TestCase):
def test_fail(self):
1/0