Skip to content

Commit a8892ae

Browse files
committed
Extract 'from_test_support' helper.
1 parent 414e4c0 commit a8892ae

File tree

1 file changed

+13
-7
lines changed
  • importlib_resources/tests/compat

1 file changed

+13
-7
lines changed

importlib_resources/tests/compat/py39.py

Lines changed: 13 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -8,21 +8,27 @@
88
from jaraco.collections import Projection
99

1010

11+
def from_test_support(*names):
12+
"""
13+
Return a SimpleNamespace of names from test.support.
14+
"""
15+
import test.support
16+
17+
return types.SimpleNamespace(**Projection(names, vars(test.support)))
18+
19+
1120
try:
1221
from test.support import import_helper # type: ignore
1322
except ImportError:
14-
import test.support
15-
16-
names = 'modules_setup', 'modules_cleanup', 'DirsOnSysPath'
17-
import_helper = types.SimpleNamespace(**Projection(names, vars(test.support)))
23+
import_helper = from_test_support(
24+
'modules_setup', 'modules_cleanup', 'DirsOnSysPath'
25+
)
1826

1927

2028
try:
2129
from test.support import os_helper # type: ignore
2230
except ImportError:
23-
24-
class os_helper: # type:ignore
25-
from test.support import temp_dir
31+
os_helper = from_test_support('temp_dir')
2632

2733

2834
try:

0 commit comments

Comments
 (0)