summaryrefslogtreecommitdiff
path: root/tests/test_files.py
diff options
context:
space:
mode:
authorStephan Richter <stephan.richter@gmail.com>2019-01-27 14:37:40 -0500
committerNed Batchelder <ned@nedbatchelder.com>2019-01-28 21:37:24 -0500
commit1655796d48cb67d7247b41a09fe5c2463b32d47a (patch)
tree44f1ffc1d491ed4161af7af0dcfdb2e4501150ec /tests/test_files.py
parent21d3b37e290796312750f207442b33afbaab14de (diff)
downloadpython-coveragepy-git-1655796d48cb67d7247b41a09fe5c2463b32d47a.tar.gz
Make sure that the cache is properly filled. (25x speedup on our system that has a large sys.path.)
It is always a bad idea to reassign the cachekey during the computation.
Diffstat (limited to 'tests/test_files.py')
-rw-r--r--tests/test_files.py13
1 files changed, 13 insertions, 0 deletions
diff --git a/tests/test_files.py b/tests/test_files.py
index b4490ea6..87b85431 100644
--- a/tests/test_files.py
+++ b/tests/test_files.py
@@ -57,6 +57,19 @@ class FilesTest(CoverageTest):
rel = os.path.join('sub', trick, 'file1.py')
self.assertEqual(files.relative_filename(abs_file(rel)), rel)
+ def test_canonical_filename_ensure_cache_hit(self):
+ self.make_file("sub/proj1/file1.py")
+ d = os.path.normpath("sub/proj1")
+ self.chdir(d)
+ files.set_relative_directory()
+ canonical_path = files.canonical_filename('sub/proj1/file1.py')
+ self.assertEqual(canonical_path, self.abs_path('file1.py'))
+ # After the filename has been converted, it should be in the cache.
+ self.assertIn('sub/proj1/file1.py', files.CANONICAL_FILENAME_CACHE)
+ self.assertEqual(
+ files.canonical_filename('sub/proj1/file1.py'),
+ self.abs_path('file1.py'))
+
@pytest.mark.parametrize("original, flat", [
(u"a/b/c.py", u"a_b_c_py"),