|
5 | 5 | importlib_util = util.import_importlib('importlib.util') |
6 | 6 |
|
7 | 7 | import os |
| 8 | +import pathlib |
8 | 9 | import string |
9 | 10 | import sys |
10 | 11 | from test import support |
@@ -676,6 +677,15 @@ def test_sep_altsep_and_sep_cache_from_source(self): |
676 | 677 | self.util.cache_from_source('\\foo\\bar\\baz/qux.py', optimization=''), |
677 | 678 | '\\foo\\bar\\baz\\__pycache__\\qux.{}.pyc'.format(self.tag)) |
678 | 679 |
|
| 680 | + @unittest.skipUnless(sys.implementation.cache_tag is not None, |
| 681 | + 'requires sys.implementation.cache_tag not be None') |
| 682 | + def test_source_from_cache_path_like_arg(self): |
| 683 | + path = pathlib.PurePath('foo', 'bar', 'baz', 'qux.py') |
| 684 | + expect = os.path.join('foo', 'bar', 'baz', '__pycache__', |
| 685 | + 'qux.{}.pyc'.format(self.tag)) |
| 686 | + self.assertEqual(self.util.cache_from_source(path, optimization=''), |
| 687 | + expect) |
| 688 | + |
679 | 689 | @unittest.skipUnless(sys.implementation.cache_tag is not None, |
680 | 690 | 'requires sys.implementation.cache_tag to not be ' |
681 | 691 | 'None') |
@@ -738,6 +748,15 @@ def test_source_from_cache_missing_optimization(self): |
738 | 748 | with self.assertRaises(ValueError): |
739 | 749 | self.util.source_from_cache(path) |
740 | 750 |
|
| 751 | + @unittest.skipUnless(sys.implementation.cache_tag is not None, |
| 752 | + 'requires sys.implementation.cache_tag to not be ' |
| 753 | + 'None') |
| 754 | + def test_source_from_cache_path_like_arg(self): |
| 755 | + path = pathlib.PurePath('foo', 'bar', 'baz', '__pycache__', |
| 756 | + 'qux.{}.pyc'.format(self.tag)) |
| 757 | + expect = os.path.join('foo', 'bar', 'baz', 'qux.py') |
| 758 | + self.assertEqual(self.util.source_from_cache(path), expect) |
| 759 | + |
741 | 760 |
|
742 | 761 | (Frozen_PEP3147Tests, |
743 | 762 | Source_PEP3147Tests |
|
0 commit comments