File tree 2 files changed +36
-0
lines changed
2 files changed +36
-0
lines changed Original file line number Diff line number Diff line change
1
+ """
2
+ Compatibility shims for getting stuff from test.support across
3
+ Python versions (for compatibility with Python 3.9 and earlier).
4
+
5
+ >>> os_helper = try_import('os_helper') or from_test_support('temp_dir')
6
+ >>> os_helper.temp_dir
7
+ <function temp_dir at ...>
8
+ """
9
+
10
+ import importlib
11
+ import types
12
+
13
+ from jaraco .context import suppress
14
+ from jaraco .collections import Projection
15
+
16
+
17
+ def from_test_support (* names ):
18
+ """
19
+ Return a SimpleNamespace of names from test.support.
20
+
21
+ >>> support = from_test_support('swap_item')
22
+ >>> support.swap_item
23
+ <function swap_item at ...>
24
+ """
25
+ import test .support
26
+
27
+ return types .SimpleNamespace (** Projection (names , vars (test .support )))
28
+
29
+
30
+ @suppress (ImportError )
31
+ def try_import (name ):
32
+ """
33
+ Attempt to import a submodule of test.support; return None if missing.
34
+ """
35
+ return importlib .import_module (f'test.support.{ name } ' )
Original file line number Diff line number Diff line change @@ -19,6 +19,7 @@ python_requires = >=3.8
19
19
install_requires =
20
20
jaraco.functools
21
21
jaraco.context
22
+ jaraco.collections
22
23
23
24
[options.extras_require]
24
25
testing =
You can’t perform that action at this time.
0 commit comments