summaryrefslogtreecommitdiff
path: root/tests/coveragetest.py
diff options
context:
space:
mode:
authorNed Batchelder <ned@nedbatchelder.com>2017-05-04 07:35:24 -0400
committerNed Batchelder <ned@nedbatchelder.com>2017-05-04 07:35:24 -0400
commit67f905e4b7002d71d7ab33b87089a876eb4ef66c (patch)
tree44bb3f7b60ca37933e1adc887367c771777cbbb2 /tests/coveragetest.py
parentb48ec04376ae5c9103bb73e1146473d70c1e5c8e (diff)
downloadpython-coveragepy-git-67f905e4b7002d71d7ab33b87089a876eb4ef66c.tar.gz
Refactor common test infrastructure for fiddling sys.path and finding files
Diffstat (limited to 'tests/coveragetest.py')
-rw-r--r--tests/coveragetest.py14
1 files changed, 14 insertions, 0 deletions
diff --git a/tests/coveragetest.py b/tests/coveragetest.py
index 0e6131fb..4d9540d0 100644
--- a/tests/coveragetest.py
+++ b/tests/coveragetest.py
@@ -31,6 +31,9 @@ from tests.helpers import run_command, SuperModuleCleaner
# Status returns for the command line.
OK, ERR = 0, 1
+# The coverage/tests directory, for all sorts of finding test helping things.
+TESTS_DIR = os.path.dirname(__file__)
+
def convert_skip_exceptions(method):
"""A decorator for test methods to convert StopEverything to SkipTest."""
@@ -490,6 +493,17 @@ class CoverageTest(
return self.squeezed_lines(report)[-1]
+class UsingModulesMixin(object):
+ """A mixin for importing modules from tests/modules and tests/moremodules."""
+
+ def setUp(self):
+ super(UsingModulesMixin, self).setUp()
+
+ # Parent class saves and restores sys.path, we can just modify it.
+ sys.path.append(self.nice_file(TESTS_DIR, 'modules'))
+ sys.path.append(self.nice_file(TESTS_DIR, 'moremodules'))
+
+
def command_line(args, **kwargs):
"""Run `args` through the CoverageScript command line.