()
| 725 | ) |
| 726 | |
| 727 | def test_import_statement(): |
| 728 | import importlib # noqa: F401 |
| 729 | # Set __package__ so relative imports work |
| 730 | with swap_item(globals(), "__package__", "test"): |
| 731 | with TestHook() as hook: |
| 732 | import importlib # noqa: F401 |
| 733 | import email # noqa: F401 |
| 734 | import pythoninfo # noqa: F401 |
| 735 | from .audit_test_data import submodule # noqa: F401 |
| 736 | import test.audit_test_data.submodule2 # noqa: F401 |
| 737 | import _testcapi # noqa: F401 |
| 738 | |
| 739 | actual = [a for e, a in hook.seen if e == "import"] |
| 740 | # Import statement ordering is different because the package is |
| 741 | # loaded first and then the submodule |
| 742 | assertSequenceEqual( |
| 743 | [ |
| 744 | ("email", None, sys.path, sys.meta_path, sys.path_hooks), |
| 745 | ("pythoninfo", None, sys.path, sys.meta_path, sys.path_hooks), |
| 746 | ("test.audit_test_data", None, sys.path, sys.meta_path, sys.path_hooks), |
| 747 | ("test.audit_test_data.submodule", None, sys.path, sys.meta_path, sys.path_hooks), |
| 748 | ("test.audit_test_data.submodule2", None, sys.path, sys.meta_path, sys.path_hooks), |
| 749 | ("_testcapi", None, sys.path, sys.meta_path, sys.path_hooks), |
| 750 | ("_testcapi", unittest.mock.ANY, None, None, None) |
| 751 | ], |
| 752 | actual, |
| 753 | ) |
| 754 | |
| 755 | if __name__ == "__main__": |
| 756 | from test.support import suppress_msvcrt_asserts |
nothing calls this directly
no test coverage detected
searching dependent graphs…