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