|
2 | 2 | machinery = test_util.import_importlib('importlib.machinery') |
3 | 3 |
|
4 | 4 | import os |
| 5 | +import re |
5 | 6 | import sys |
6 | 7 | import unittest |
7 | 8 | from test import support |
| 9 | +from distutils.util import get_platform |
8 | 10 | from contextlib import contextmanager |
9 | 11 | from .util import temp_module |
10 | 12 |
|
@@ -83,3 +85,25 @@ def test_module_not_found(self): |
83 | 85 | (Frozen_WindowsRegistryFinderTests, |
84 | 86 | Source_WindowsRegistryFinderTests |
85 | 87 | ) = test_util.test_both(WindowsRegistryFinderTests, machinery=machinery) |
| 88 | + |
| 89 | +@unittest.skipUnless(sys.platform.startswith('win'), 'requires Windows') |
| 90 | +class WindowsExtensionSuffixTests: |
| 91 | + def test_tagged_suffix(self): |
| 92 | + suffixes = self.machinery.EXTENSION_SUFFIXES |
| 93 | + expected_tag = ".cp{0.major}{0.minor}-{1}.pyd".format(sys.version_info, |
| 94 | + re.sub('[^a-zA-Z0-9]', '_', get_platform())) |
| 95 | + try: |
| 96 | + untagged_i = suffixes.index(".pyd") |
| 97 | + except ValueError: |
| 98 | + untagged_i = suffixes.index("_d.pyd") |
| 99 | + expected_tag = "_d" + expected_tag |
| 100 | + |
| 101 | + self.assertIn(expected_tag, suffixes) |
| 102 | + |
| 103 | + # Ensure the tags are in the correct order |
| 104 | + tagged_i = suffixes.index(expected_tag) |
| 105 | + self.assertLess(tagged_i, untagged_i) |
| 106 | + |
| 107 | +(Frozen_WindowsExtensionSuffixTests, |
| 108 | + Source_WindowsExtensionSuffixTests |
| 109 | + ) = test_util.test_both(WindowsExtensionSuffixTests, machinery=machinery) |
0 commit comments