← Back to team overview

yellow team mailing list archive

[Merge] lp:~yellow/subunit/test-count into lp:subunit

 

Gary Poster has proposed merging lp:~yellow/subunit/test-count into lp:subunit.

Requested reviews:
  Subunit Developers (subunit)

For more details, see:
https://code.launchpad.net/~yellow/subunit/test-count/+merge/103717

This branch changes the semantics of testsRun in a TestResultFilter to count the total number of tests run, not the number of tests filtered.

Whether these semantics are correct is up for debate.  We're obviously proposing that they are.  That said, these changes primarily exist to make the testrepository change in lp:~yellow/testrepository/bug988481 cleaner.  We could instead continue to subclass in testrepository, of course.

This is work done by Benji York and Brad Crittenden; I'm just helping out with the MP.
-- 
https://code.launchpad.net/~yellow/subunit/test-count/+merge/103717
Your team Launchpad Yellow Squad is subscribed to branch lp:~yellow/subunit/test-count.
=== modified file 'python/subunit/test_results.py'
--- python/subunit/test_results.py	2012-04-20 11:32:41 +0000
+++ python/subunit/test_results.py	2012-04-26 15:20:26 +0000
@@ -407,8 +407,20 @@
         self._buffered_calls.append(
             ('addUnexpectedSuccess', [test], {'details': details}))
 
+    def _get_concrete_result(self):
+        # This assumes that the test result we actually care about is
+        # decorated and that we can find our way to the one we care about.
+        concrete = self
+        while True:
+            next = getattr(concrete, 'decorated', None)
+            if next is None:
+                return concrete
+            concrete = next
+
     def _filtered(self):
         self._current_test_filtered = True
+        concrete = self._get_concrete_result()
+        concrete.testsRun += 1
 
     def _failure_expected(self, test):
         return (test.id() in self._fixup_expected_failures)

=== modified file 'python/subunit/tests/test_subunit_filter.py'
--- python/subunit/tests/test_subunit_filter.py	2011-05-09 21:00:42 +0000
+++ python/subunit/tests/test_subunit_filter.py	2012-04-26 15:20:26 +0000
@@ -75,7 +75,6 @@
         self.assertEqual(['failed'],
             [failure[0].id() for failure in
             filtered_result.failures])
-        self.assertEqual(4, filtered_result.testsRun)
 
     def test_exclude_errors(self):
         filtered_result = unittest.TestResult()
@@ -86,7 +85,6 @@
         self.assertEqual(['failed'],
             [failure[0].id() for failure in
             filtered_result.failures])
-        self.assertEqual(3, filtered_result.testsRun)
 
     def test_fixup_expected_failures(self):
         filtered_result = unittest.TestResult()
@@ -96,7 +94,6 @@
         self.assertEqual(['failed', 'todo'],
             [failure[0].id() for failure in filtered_result.expectedFailures])
         self.assertEqual([], filtered_result.failures)
-        self.assertEqual(4, filtered_result.testsRun)
 
     def test_fixup_expected_errors(self):
         filtered_result = unittest.TestResult()
@@ -106,7 +103,6 @@
         self.assertEqual(['error', 'todo'],
             [failure[0].id() for failure in filtered_result.expectedFailures])
         self.assertEqual([], filtered_result.errors)
-        self.assertEqual(4, filtered_result.testsRun)
 
     def test_fixup_unexpected_success(self):
         filtered_result = unittest.TestResult()
@@ -115,7 +111,6 @@
         self.run_tests(result_filter)
         self.assertEqual(['passed'],
             [passed.id() for passed in filtered_result.unexpectedSuccesses])
-        self.assertEqual(5, filtered_result.testsRun)
 
     def test_exclude_failure(self):
         filtered_result = unittest.TestResult()
@@ -126,7 +121,6 @@
         self.assertEqual([],
             [failure[0].id() for failure in
             filtered_result.failures])
-        self.assertEqual(3, filtered_result.testsRun)
 
     def test_exclude_skips(self):
         filtered_result = subunit.TestResultStats(None)
@@ -134,7 +128,6 @@
         self.run_tests(result_filter)
         self.assertEqual(0, filtered_result.skipped_tests)
         self.assertEqual(2, filtered_result.failed_tests)
-        self.assertEqual(3, filtered_result.testsRun)
 
     def test_include_success(self):
         """Successes can be included if requested."""
@@ -153,13 +146,13 @@
         """You can filter by predicate callbacks"""
         filtered_result = unittest.TestResult()
         def filter_cb(test, outcome, err, details):
-            return outcome == 'success'
+            return outcome == 'error'
         result_filter = TestResultFilter(filtered_result,
             filter_predicate=filter_cb,
             filter_success=False)
         self.run_tests(result_filter)
-        # Only success should pass
-        self.assertEqual(1, filtered_result.testsRun)
+        # Only errors should pass
+        self.assertEqual(1, len(filtered_result.errors))
 
     def test_time_ordering_preserved(self):
         # Passing a subunit stream through TestResultFilter preserves the


Follow ups