Skip to content

Commit 3531507

Browse files
committed
Fix test failures on older Pythons with os_helper shim. Copied 'from_test_support' from importlib_resources.
1 parent f16e114 commit 3531507

File tree

4 files changed

+22
-5
lines changed

4 files changed

+22
-5
lines changed

setup.cfg

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@ testing =
3737
pyfakefs
3838
flufl.flake8
3939
pytest-perf >= 0.9.2
40+
jaraco.collections
4041

4142
docs =
4243
# upstream

tests/fixtures.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
import functools
1010
import contextlib
1111

12-
from .py39compat import FS_NONASCII
12+
from .py39compat import os_helper
1313

1414
from . import _path
1515
from ._path import FilesSpec
@@ -335,7 +335,9 @@ def record_names(file_defs):
335335

336336
class FileBuilder:
337337
def unicode_filename(self):
338-
return FS_NONASCII or self.skip("File system does not support non-ascii.")
338+
return os_helper.FS_NONASCII or self.skip(
339+
"File system does not support non-ascii."
340+
)
339341

340342

341343
def DALS(str):

tests/py39compat.py

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,18 @@
1+
import types
2+
3+
from jaraco.collections import Projection
4+
5+
6+
def from_test_support(*names):
7+
"""
8+
Return a SimpleNamespace of names from test.support.
9+
"""
10+
import test.support
11+
12+
return types.SimpleNamespace(**Projection(names, vars(test.support)))
13+
14+
115
try:
2-
from test.support.os_helper import FS_NONASCII
16+
from test.support import os_helper # type: ignore
317
except ImportError:
4-
from test.support import FS_NONASCII # noqa
18+
os_helper = from_test_support('FS_NONASCII', 'skip_unless_symlink')

tests/test_main.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
import importlib
66
import importlib_metadata
77
import contextlib
8-
from test.support import os_helper
8+
from .py39compat import os_helper
99

1010
import pyfakefs.fake_filesystem_unittest as ffs
1111

0 commit comments

Comments
 (0)