| 2691 | |
| 2692 | @classmethod |
| 2693 | def setUpClass(cls): |
| 2694 | spec = importlib.util.find_spec(cls.NAME) |
| 2695 | cls.LOADER = type(spec.loader) |
| 2696 | |
| 2697 | # Apple extensions must be distributed as frameworks. This requires |
| 2698 | # a specialist loader, and we need to differentiate between the |
| 2699 | # spec.origin and the original file location. |
| 2700 | if is_apple_mobile: |
| 2701 | assert cls.LOADER is AppleFrameworkLoader |
| 2702 | |
| 2703 | cls.ORIGIN = spec.origin |
| 2704 | with open(spec.origin + ".origin", "r") as f: |
| 2705 | cls.FILE = os.path.join( |
| 2706 | os.path.dirname(sys.executable), |
| 2707 | f.read().strip() |
| 2708 | ) |
| 2709 | else: |
| 2710 | assert cls.LOADER is ExtensionFileLoader |
| 2711 | |
| 2712 | cls.ORIGIN = spec.origin |
| 2713 | cls.FILE = spec.origin |
| 2714 | |
| 2715 | # Start fresh. |
| 2716 | cls.clean_up() |
| 2717 | |
| 2718 | def tearDown(self): |
| 2719 | # Clean up the module. |