summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNed Batchelder <ned@nedbatchelder.com>2012-10-27 17:11:02 -0400
committerNed Batchelder <ned@nedbatchelder.com>2012-10-27 17:11:02 -0400
commitccbd6adce77cd07e31539f1c93c020de4731f52e (patch)
treeabad676af249728a76c285aa1f0f1cf3fc47b3e9
parent5df3b4593d26ed659e285f633a9acd11759845c8 (diff)
downloadpython-coveragepy-ccbd6adce77cd07e31539f1c93c020de4731f52e.tar.gz
Make a mixin for a test: super is hard, let's go shopping.
-rw-r--r--test/coveragetest.py4
-rw-r--r--test/test_api.py12
2 files changed, 12 insertions, 4 deletions
diff --git a/test/coveragetest.py b/test/coveragetest.py
index 627635f..61a7519 100644
--- a/test/coveragetest.py
+++ b/test/coveragetest.py
@@ -32,6 +32,8 @@ class CoverageTest(TestCase):
run_in_temp_dir = True
def setUp(self):
+ super(CoverageTest, self).setUp()
+
# Tell newer unittest implementations to print long helpful messages.
self.longMessage = True
@@ -71,6 +73,8 @@ class CoverageTest(TestCase):
self.old_modules = dict(sys.modules)
def tearDown(self):
+ super(CoverageTest, self).tearDown()
+
# Restore the original sys.path.
sys.path = self.old_syspath
diff --git a/test/test_api.py b/test/test_api.py
index 48f1082..3f51188 100644
--- a/test/test_api.py
+++ b/test/test_api.py
@@ -346,13 +346,13 @@ class ApiTest(CoverageTest):
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'))
@@ -361,7 +361,11 @@ class SourceOmitIncludeTest(CoverageTest):
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.