Skip to content

Commit

Permalink
Fix test failures on older Pythons with os_helper shim. Copied 'from_…
Browse files Browse the repository at this point in the history
…test_support' from importlib_resources.
  • Loading branch information
jaraco committed Mar 20, 2024
1 parent f16e114 commit 3531507
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 5 deletions.
1 change: 1 addition & 0 deletions setup.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ testing =
pyfakefs
flufl.flake8
pytest-perf >= 0.9.2
jaraco.collections

docs =
# upstream
Expand Down
6 changes: 4 additions & 2 deletions tests/fixtures.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
import functools
import contextlib

from .py39compat import FS_NONASCII
from .py39compat import os_helper

from . import _path
from ._path import FilesSpec
Expand Down Expand Up @@ -335,7 +335,9 @@ def record_names(file_defs):

class FileBuilder:
def unicode_filename(self):
return FS_NONASCII or self.skip("File system does not support non-ascii.")
return os_helper.FS_NONASCII or self.skip(
"File system does not support non-ascii."
)


def DALS(str):
Expand Down
18 changes: 16 additions & 2 deletions tests/py39compat.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,18 @@
import types

from jaraco.collections import Projection


def from_test_support(*names):
"""
Return a SimpleNamespace of names from test.support.
"""
import test.support

return types.SimpleNamespace(**Projection(names, vars(test.support)))


try:
from test.support.os_helper import FS_NONASCII
from test.support import os_helper # type: ignore
except ImportError:
from test.support import FS_NONASCII # noqa
os_helper = from_test_support('FS_NONASCII', 'skip_unless_symlink')
2 changes: 1 addition & 1 deletion tests/test_main.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
import importlib
import importlib_metadata
import contextlib
from test.support import os_helper
from .py39compat import os_helper

import pyfakefs.fake_filesystem_unittest as ffs

Expand Down

0 comments on commit 3531507

Please sign in to comment.