|
1 | 1 | from pathlib import Path |
2 | | -from test.support.import_helper import unload, CleanImport |
3 | | -from test.support.warnings_helper import check_warnings, ignore_warnings |
| 2 | +from test.support.import_helper import unload |
| 3 | +from test.support.warnings_helper import check_warnings |
4 | 4 | import unittest |
5 | 5 | import sys |
6 | 6 | import importlib |
@@ -231,7 +231,7 @@ def test_walk_packages_raises_on_string_or_bytes_input(self): |
231 | 231 | with self.assertRaises((TypeError, ValueError)): |
232 | 232 | list(pkgutil.walk_packages(bytes_input)) |
233 | 233 |
|
234 | | - @unittest.expectedFailure # TODO: RUSTPYTHON |
| 234 | + @unittest.expectedFailure # TODO: RUSTPYTHON |
235 | 235 | def test_name_resolution(self): |
236 | 236 | import logging |
237 | 237 | import logging.handlers |
@@ -608,73 +608,6 @@ class ImportlibMigrationTests(unittest.TestCase): |
608 | 608 | # PEP 302 emulation in this module is in the process of being |
609 | 609 | # deprecated in favour of importlib proper |
610 | 610 |
|
611 | | - @unittest.skipIf(__name__ == '__main__', 'not compatible with __main__') |
612 | | - @ignore_warnings(category=DeprecationWarning) |
613 | | - def test_get_loader_handles_missing_loader_attribute(self): |
614 | | - global __loader__ |
615 | | - this_loader = __loader__ |
616 | | - del __loader__ |
617 | | - try: |
618 | | - self.assertIsNotNone(pkgutil.get_loader(__name__)) |
619 | | - finally: |
620 | | - __loader__ = this_loader |
621 | | - |
622 | | - @ignore_warnings(category=DeprecationWarning) |
623 | | - def test_get_loader_handles_missing_spec_attribute(self): |
624 | | - name = 'spam' |
625 | | - mod = type(sys)(name) |
626 | | - del mod.__spec__ |
627 | | - with CleanImport(name): |
628 | | - try: |
629 | | - sys.modules[name] = mod |
630 | | - loader = pkgutil.get_loader(name) |
631 | | - finally: |
632 | | - sys.modules.pop(name, None) |
633 | | - self.assertIsNone(loader) |
634 | | - |
635 | | - @ignore_warnings(category=DeprecationWarning) |
636 | | - def test_get_loader_handles_spec_attribute_none(self): |
637 | | - name = 'spam' |
638 | | - mod = type(sys)(name) |
639 | | - mod.__spec__ = None |
640 | | - with CleanImport(name): |
641 | | - try: |
642 | | - sys.modules[name] = mod |
643 | | - loader = pkgutil.get_loader(name) |
644 | | - finally: |
645 | | - sys.modules.pop(name, None) |
646 | | - self.assertIsNone(loader) |
647 | | - |
648 | | - @ignore_warnings(category=DeprecationWarning) |
649 | | - def test_get_loader_None_in_sys_modules(self): |
650 | | - name = 'totally bogus' |
651 | | - sys.modules[name] = None |
652 | | - try: |
653 | | - loader = pkgutil.get_loader(name) |
654 | | - finally: |
655 | | - del sys.modules[name] |
656 | | - self.assertIsNone(loader) |
657 | | - |
658 | | - def test_get_loader_is_deprecated(self): |
659 | | - with check_warnings( |
660 | | - (r".*\bpkgutil.get_loader\b.*", DeprecationWarning), |
661 | | - ): |
662 | | - res = pkgutil.get_loader("sys") |
663 | | - self.assertIsNotNone(res) |
664 | | - |
665 | | - def test_find_loader_is_deprecated(self): |
666 | | - with check_warnings( |
667 | | - (r".*\bpkgutil.find_loader\b.*", DeprecationWarning), |
668 | | - ): |
669 | | - res = pkgutil.find_loader("sys") |
670 | | - self.assertIsNotNone(res) |
671 | | - |
672 | | - @ignore_warnings(category=DeprecationWarning) |
673 | | - def test_find_loader_missing_module(self): |
674 | | - name = 'totally bogus' |
675 | | - loader = pkgutil.find_loader(name) |
676 | | - self.assertIsNone(loader) |
677 | | - |
678 | 611 | def test_get_importer_avoids_emulation(self): |
679 | 612 | # We use an illegal path so *none* of the path hooks should fire |
680 | 613 | with check_warnings() as w: |
|
0 commit comments