Rev 5392: add a failing test that the subunit stream doesn't contain the log info. in http://bazaar.launchpad.net/~jameinel/bzr/2.3-filter-tests

John Arbash Meinel john at arbash-meinel.com
Fri Sep 24 17:53:42 BST 2010


At http://bazaar.launchpad.net/~jameinel/bzr/2.3-filter-tests

------------------------------------------------------------
revno: 5392
revision-id: john at arbash-meinel.com-20100924165327-54m2jfhmz5mo69b3
parent: john at arbash-meinel.com-20100924164438-1kbgh1yp263r8jqo
committer: John Arbash Meinel <john at arbash-meinel.com>
branch nick: 2.3-filter-tests
timestamp: Fri 2010-09-24 11:53:27 -0500
message:
  add a failing test that the subunit stream doesn't contain the log info.
-------------- next part --------------
=== modified file 'bzrlib/tests/test_selftest.py'
--- a/bzrlib/tests/test_selftest.py	2010-09-24 16:44:38 +0000
+++ b/bzrlib/tests/test_selftest.py	2010-09-24 16:53:27 +0000
@@ -1739,17 +1739,6 @@
         details = test.getDetails()
         self.assertTrue('log' in details)
 
-    # def test_success_has_no_log(self):
-    #     # TODO: We need to test the Subunit implementation here
-    #     class Test(tests.TestCase):
-    #         def test_success(self):
-    #             mutter('this test succeeded')
-    #     result = self._run_test(Test('test_success'))
-    #     self.assertEqual(1, len(result.errors))
-    #     result_content = result.errors[0][1]
-    #     self.assertContainsRe(result_content, 'Text attachment: log')
-    #     self.assertContainsRe(result_content, 'this test errored')
-
 
 # NB: Don't delete this; it's not actually from 0.11!
 @deprecated_function(deprecated_in((0, 11, 0)))
@@ -1910,7 +1899,7 @@
                 tree.branch.repository.bzrdir.root_transport)
 
 
-class SelfTestHelper:
+class SelfTestHelper(object):
 
     def run_selftest(self, **kwargs):
         """Run selftest returning its output."""
@@ -2067,6 +2056,32 @@
             load_list='missing file name', list_only=True)
 
 
+class TestSubunitLogDetails(tests.TestCase, SelfTestHelper):
+
+    _test_needs_features = [features.subunit]
+
+    def run_subunit_stream(self, test_suite_factory):
+        from subunit import ProtocolTestCase
+        stream = self.run_selftest(runner_class=tests.SubUnitBzrRunner,
+            test_suite_factory=test_suite_factory)
+        test = ProtocolTestCase(stream)
+        result = unittest.TestResult()
+        test.run(result)
+        return stream, result
+
+    def test_success_has_no_log(self):
+        class Test(tests.TestCase):
+            def test_success(self):
+                mutter('this test succeeds')
+        def factory():
+            return TestUtil.TestSuite([Test('test_success')])
+        stream, result = self.run_subunit_stream(factory)
+        self.assertEqual(1, result.testsRun)
+        content = stream.getvalue()
+        self.assertNotContainsRe(content, '(?m)^log$')
+        self.assertNotContainsRe(content, 'this test succeeds')
+
+
 class TestRunBzr(tests.TestCase):
 
     out = ''



More information about the bazaar-commits mailing list