Fix imp.cache_from_source() if the directory name contains a dot

If the directory name contains a dot but not the filename, don't strip at the
dot.
This commit is contained in:
Victor Stinner 2011-03-14 15:05:12 -04:00
parent fe19d21815
commit ccbf475dfd
2 changed files with 6 additions and 2 deletions

View file

@ -210,6 +210,10 @@ class PEP3147Tests(unittest.TestCase):
self.assertEqual(
imp.cache_from_source('/foo/bar/baz/qux.py', True),
'/foo/bar/baz/__pycache__/qux.{}.pyc'.format(self.tag))
# Directory with a dot, filename without dot
self.assertEqual(
imp.cache_from_source('/foo.bar/file', True),
'/foo.bar/__pycache__/file{}.pyc'.format(self.tag))
def test_cache_from_source_optimized(self):
# Given the path to a .py file, return the path to its PEP 3147