diff options
Diffstat (limited to 'tests')
-rw-r--r-- | tests/coveragetest.py | 12 | ||||
-rw-r--r-- | tests/test_api.py | 6 | ||||
-rw-r--r-- | tests/test_oddball.py | 3 | ||||
-rw-r--r-- | tests/test_xml.py | 5 |
4 files changed, 9 insertions, 17 deletions
diff --git a/tests/coveragetest.py b/tests/coveragetest.py index 306df3b8..cb5d6711 100644 --- a/tests/coveragetest.py +++ b/tests/coveragetest.py @@ -109,16 +109,6 @@ class CoverageTest( invalidate_import_caches() - def import_local_file(self, modname, modfile=None): - """Import a local file as a module. - - Opens a file in the current directory named `modname`.py, imports it - as `modname`, and returns the module object. `modfile` is the file to - import if it isn't in the current directory. - - """ - return import_local_file(modname, modfile) - def start_import_stop(self, cov, modname, modfile=None): """Start coverage, import a file, then stop coverage. @@ -132,7 +122,7 @@ class CoverageTest( cov.start() try: # pragma: nested # Import the Python file, executing it. - mod = self.import_local_file(modname, modfile) + mod = import_local_file(modname, modfile) finally: # pragma: nested # Stop coverage.py. cov.stop() diff --git a/tests/test_api.py b/tests/test_api.py index 6d87fc01..eaeabcb4 100644 --- a/tests/test_api.py +++ b/tests/test_api.py @@ -11,7 +11,7 @@ import warnings import coverage from coverage import env -from coverage.backward import StringIO +from coverage.backward import StringIO, import_local_file from coverage.misc import CoverageException from coverage.report import Reporter @@ -286,9 +286,9 @@ class ApiTest(CoverageTest): self.make_code1_code2() cov = coverage.Coverage() cov.start() - self.import_local_file("code1") + import_local_file("code1") cov.save() - self.import_local_file("code2") + import_local_file("code2") cov.stop() self.check_code1_code2(cov) diff --git a/tests/test_oddball.py b/tests/test_oddball.py index 5a331a29..1fa369aa 100644 --- a/tests/test_oddball.py +++ b/tests/test_oddball.py @@ -10,6 +10,7 @@ import pytest import coverage from coverage import env +from coverage.backward import import_local_file from coverage.files import abs_file from tests.coveragetest import CoverageTest @@ -333,7 +334,7 @@ class ExceptionTest(CoverageTest): # Import all the modules before starting coverage, so the def lines # won't be in all the results. for mod in "oops fly catch doit".split(): - self.import_local_file(mod) + import_local_file(mod) # Each run nests the functions differently to get different # combinations of catching exceptions and letting them fly. diff --git a/tests/test_xml.py b/tests/test_xml.py index 9f1781af..b59f8732 100644 --- a/tests/test_xml.py +++ b/tests/test_xml.py @@ -8,6 +8,7 @@ import os.path import re import coverage +from coverage.backward import import_local_file from coverage.files import abs_file from tests.coveragetest import CoverageTest @@ -166,8 +167,8 @@ class XmlReportTest(XmlTestHelpers, CoverageTest): self.make_file("also/over/there/bar.py", "b = 2") cov = coverage.Coverage(source=["src/main", "also/over/there", "not/really"]) cov.start() - mod_foo = self.import_local_file("foo", "src/main/foo.py") # pragma: nested - mod_bar = self.import_local_file("bar", "also/over/there/bar.py") # pragma: nested + mod_foo = import_local_file("foo", "src/main/foo.py") # pragma: nested + mod_bar = import_local_file("bar", "also/over/there/bar.py") # pragma: nested cov.stop() # pragma: nested cov.xml_report([mod_foo, mod_bar], outfile="-") xml = self.stdout() |