Skip to content

Commit d2d17a0

Browse files
committed
Add test
1 parent 7a277ec commit d2d17a0

File tree

1 file changed

+12
-0
lines changed

1 file changed

+12
-0
lines changed

Lib/test/test_importlib/test_util.py

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -580,6 +580,18 @@ def test_cache_from_source_respects_pycache_prefix_relative(self):
580580
self.util.cache_from_source(path, optimization=''),
581581
os.path.normpath(expect))
582582

583+
@unittest.skipIf(sys.implementation.cache_tag is None,
584+
'requires sys.implementation.cache_tag to not be None')
585+
def test_cache_from_source_in_root_with_pycache_prefix(self):
586+
# Regression test for gh-82916
587+
pycache_prefix = os.path.join(os.path.sep, 'tmp', 'bytecode')
588+
path = 'qux.py'
589+
expect = os.path.join(os.path.sep, 'tmp', 'bytecode',
590+
f'qux.{self.tag}.pyc')
591+
with util.temporary_pycache_prefix(pycache_prefix):
592+
with os_helper.change_cwd('/'):
593+
self.assertEqual(self.util.cache_from_source(path), expect)
594+
583595
@unittest.skipIf(sys.implementation.cache_tag is None,
584596
'requires sys.implementation.cache_tag to not be None')
585597
def test_source_from_cache_inside_pycache_prefix(self):

0 commit comments

Comments
 (0)