diff options
-rw-r--r-- | coverage/backunittest.py | 5 | ||||
-rw-r--r-- | tests/test_summary_class.py | 23 |
2 files changed, 10 insertions, 18 deletions
diff --git a/coverage/backunittest.py b/coverage/backunittest.py index 09574ccb..29fea86f 100644 --- a/coverage/backunittest.py +++ b/coverage/backunittest.py @@ -40,3 +40,8 @@ class TestCase(unittest.TestCase): if not unittest_has('assertRegex'): def assertRegex(self, *args, **kwargs): return self.assertRegexpMatches(*args, **kwargs) + + if not unittest_has('assertNotIn'): + def assertNotIn(self, needle, haystack): + self.assertTrue(needle not in haystack) + diff --git a/tests/test_summary_class.py b/tests/test_summary_class.py index bc4466bc..fb455920 100644 --- a/tests/test_summary_class.py +++ b/tests/test_summary_class.py @@ -5,17 +5,10 @@ """Test text-based summary reporter for coverage.py""" import collections -import unittest import os.path import sys -if sys.version_info < (3, ): - try: - from cStringIO import StringIO - except ImportError: - from StringIO import StringIO -else: - from io import StringIO -from coverage import summary, data, control, config +from coverage.backward import StringIO +from coverage import backunittest, config, control, data, summary LINES_1 = { __file__: {-1: 1, 7: 1}, @@ -23,7 +16,7 @@ LINES_1 = { } -class TestSummaryReporterConfiguration(unittest.TestCase): +class TestSummaryReporterConfiguration(backunittest.TestCase): def get_coverage_data(self, lines=LINES_1): """Get a CoverageData object that includes the requested lines.""" data1 = data.CoverageData() @@ -57,10 +50,7 @@ class TestSummaryReporterConfiguration(unittest.TestCase): opts = config.CoverageConfig() opts.from_args(show_missing=True) report = self.get_summary_text(data, opts) - if sys.version_info > (2, 7): - self.assertIn('Missing', report) - else: - self.assertTrue('Missing' in report) + self.assertTrue('Missing' in report) self.assertNotIn('Branch', report) def test_sort_report(self): @@ -73,7 +63,4 @@ class TestSummaryReporterConfiguration(unittest.TestCase): filename = os.path.splitext(os.path.basename(__file__))[0] location1 = report.find('helpers') location2 = report.find(filename) - if sys.version_info > (2, 7): - self.assertLess(location1, location2) - else: - self.assertTrue(location1 < location2) + self.assertTrue(location1 < location2) |