forked from RustPython/RustPython
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtest_path_hook.py
More file actions
33 lines (22 loc) · 1.01 KB
/
test_path_hook.py
File metadata and controls
33 lines (22 loc) · 1.01 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
from test.test_importlib import util
machinery = util.import_importlib('importlib.machinery')
import unittest
@unittest.skipIf(util.EXTENSIONS is None or util.EXTENSIONS.filename is None,
'dynamic loading not supported or test module not available')
class PathHookTests:
"""Test the path hook for extension modules."""
# XXX Should it only succeed for pre-existing directories?
# XXX Should it only work for directories containing an extension module?
def hook(self, entry):
return self.machinery.FileFinder.path_hook(
(self.machinery.ExtensionFileLoader,
self.machinery.EXTENSION_SUFFIXES))(entry)
def test_success(self):
# Path hook should handle a directory where a known extension module
# exists.
self.assertHasAttr(self.hook(util.EXTENSIONS.path), 'find_spec')
(Frozen_PathHooksTests,
Source_PathHooksTests
) = util.test_both(PathHookTests, machinery=machinery)
if __name__ == '__main__':
unittest.main()