(self)
| 615 | |
| 616 | @skip_if_dont_write_bytecode |
| 617 | def test_file_to_source(self): |
| 618 | # check if __file__ points to the source file where available |
| 619 | source = TESTFN + ".py" |
| 620 | with open(source, "w", encoding='utf-8') as f: |
| 621 | f.write("test = None\n") |
| 622 | |
| 623 | sys.path.insert(0, os.curdir) |
| 624 | try: |
| 625 | mod = __import__(TESTFN) |
| 626 | self.assertEndsWith(mod.__file__, '.py') |
| 627 | os.remove(source) |
| 628 | del sys.modules[TESTFN] |
| 629 | make_legacy_pyc(source) |
| 630 | importlib.invalidate_caches() |
| 631 | mod = __import__(TESTFN) |
| 632 | base, ext = os.path.splitext(mod.__file__) |
| 633 | self.assertEqual(ext, '.pyc') |
| 634 | finally: |
| 635 | del sys.path[0] |
| 636 | remove_files(TESTFN) |
| 637 | if TESTFN in sys.modules: |
| 638 | del sys.modules[TESTFN] |
| 639 | |
| 640 | def test_import_by_filename(self): |
| 641 | path = os.path.abspath(TESTFN) |
nothing calls this directly
no test coverage detected