Commits

Ned Batchelder  committed b6c13fd

Make a mixin for a test: super is hard, let's go shopping.

  • Participants
  • Parent commits d0217f6

Comments (0)

Files changed (2)

File test/coveragetest.py

     run_in_temp_dir = True
 
     def setUp(self):
+        super(CoverageTest, self).setUp()
+
         # Tell newer unittest implementations to print long helpful messages.
         self.longMessage = True
 
         self.old_modules = dict(sys.modules)
 
     def tearDown(self):
+        super(CoverageTest, self).tearDown()
+
         # Restore the original sys.path.
         sys.path = self.old_syspath
 

File test/test_api.py

         cov.report()
 
 
-class SourceOmitIncludeTest(CoverageTest):
-    """Test using `source`, `omit` and `include` when measuring code."""
+class UsingModulesMixin(object):
+    """A mixin for importing modules from test/modules and test/moremodules."""
 
     run_in_temp_dir = False
 
     def setUp(self):
-        super(SourceOmitIncludeTest, self).setUp()
+        super(UsingModulesMixin, self).setUp()
         # Parent class saves and restores sys.path, we can just modify it.
         self.old_dir = os.getcwd()
         os.chdir(self.nice_file(os.path.dirname(__file__), 'modules'))
 
     def tearDown(self):
         os.chdir(self.old_dir)
-        super(SourceOmitIncludeTest, self).tearDown()
+        super(UsingModulesMixin, self).tearDown()
+
+
+class SourceOmitIncludeTest(UsingModulesMixin, CoverageTest):
+    """Test using `source`, `omit` and `include` when measuring code."""
 
     def coverage_usepkgs_summary(self, **kwargs):
         """Run coverage on usepkgs and return the line summary.