diff options
author | Ned Batchelder <ned@nedbatchelder.com> | 2021-03-21 17:20:23 -0400 |
---|---|---|
committer | Ned Batchelder <ned@nedbatchelder.com> | 2021-03-22 07:04:13 -0400 |
commit | 66173dc24db5e6800483e0faddf583e80d9eb9b3 (patch) | |
tree | 290844e83b57e29f9ff20799fa0010978990bedb /tests/coveragetest.py | |
parent | e613a75b7c20bec00b4564f2d87812a8fd7b8e11 (diff) | |
download | python-coveragepy-git-66173dc24db5e6800483e0faddf583e80d9eb9b3.tar.gz |
refactor: nice_file can be used as a function
Diffstat (limited to 'tests/coveragetest.py')
-rw-r--r-- | tests/coveragetest.py | 21 |
1 files changed, 8 insertions, 13 deletions
diff --git a/tests/coveragetest.py b/tests/coveragetest.py index 65678d52..415dd4ab 100644 --- a/tests/coveragetest.py +++ b/tests/coveragetest.py @@ -22,7 +22,7 @@ from coverage.backward import StringIO, import_local_file, string_class, shlex_q from coverage.cmdline import CoverageScript from tests.helpers import arcs_to_arcz_repr, arcz_to_arcs, assert_count_equal -from tests.helpers import run_command +from tests.helpers import nice_file, run_command from tests.mixins import PytestBase, StdStreamCapturingMixin, SysPathModulesMixin, TempDirMixin @@ -262,15 +262,10 @@ class CoverageTest( finally: cov._warn = original_warn - def nice_file(self, *fparts): - """Canonicalize the file name composed of the parts in `fparts`.""" - fname = os.path.join(*fparts) - return os.path.normcase(os.path.abspath(os.path.realpath(fname))) - def assert_same_files(self, flist1, flist2): """Assert that `flist1` and `flist2` are the same set of file names.""" - flist1_nice = [self.nice_file(f) for f in flist1] - flist2_nice = [self.nice_file(f) for f in flist2] + flist1_nice = [nice_file(f) for f in flist1] + flist2_nice = [nice_file(f) for f in flist2] assert_count_equal(flist1_nice, flist2_nice) def assert_exists(self, fname): @@ -393,8 +388,8 @@ class CoverageTest( if env.JYTHON: pythonpath_name = "JYTHONPATH" # pragma: only jython - testmods = self.nice_file(self.working_root(), 'tests/modules') - zipfile = self.nice_file(self.working_root(), 'tests/zipmods.zip') + testmods = nice_file(self.working_root(), "tests/modules") + zipfile = nice_file(self.working_root(), "tests/zipmods.zip") pypath = os.getenv(pythonpath_name, '') if pypath: pypath += os.pathsep @@ -407,7 +402,7 @@ class CoverageTest( def working_root(self): """Where is the root of the coverage.py working tree?""" - return os.path.dirname(self.nice_file(coverage.__file__, "..")) + return os.path.dirname(nice_file(coverage.__file__, "..")) def report_from_command(self, cmd): """Return the report from the `cmd`, with some convenience added.""" @@ -451,8 +446,8 @@ class UsingModulesMixin(object): super(UsingModulesMixin, self).setup_test() # 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')) + sys.path.append(nice_file(TESTS_DIR, "modules")) + sys.path.append(nice_file(TESTS_DIR, "moremodules")) def command_line(args): |