Skip to content

Commit 3c5db6c

Browse files
committed
Remove the need to import the "undefined" module in test
- the module is not maintained and very trivial
1 parent 816d114 commit 3c5db6c

File tree

5 files changed

+39
-8
lines changed

5 files changed

+39
-8
lines changed

.github/workflows/testsuite.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -116,7 +116,7 @@ jobs:
116116
run: |
117117
pip install -r requirements.txt
118118
pip install -U pytest==${{ matrix.pytest-version }}
119-
pip install opentimelineio undefined pandas parquet pyarrow
119+
pip install opentimelineio pandas parquet pyarrow
120120
pip install -e .
121121
if [[ '${{ matrix.pytest-version }}' == '4.0.2' ]]; then
122122
pip install -U attrs==19.1.0

CHANGES.md

+8-3
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,10 @@ The released versions correspond to PyPI releases.
99
* removed the argument `module_cleanup_mode`, that was introduced as a temporary workaround
1010
in the previous version - related problems shall be handled using a cleanup handler
1111

12+
### Enhancements
13+
* added support for `O_NOFOLLOW` and `O_DIRECTORY` flags in `os.open`
14+
(see [#972](../../issues/972) and [#974](../../issues/974))
15+
1216
### Fixes
1317
* fixed a specific problem on reloading a pandas-related module (see [#947](../../issues/947)),
1418
added possibility for unload hooks for specific modules
@@ -26,9 +30,10 @@ The released versions correspond to PyPI releases.
2630
* fixed permission problem with `shutil.rmtree` if emulating Windows under POSIX
2731
(see [#979](../../issues/979))
2832

29-
### Enhancements
30-
* added support for `O_NOFOLLOW` and `O_DIRECTORY` flags in `os.open`
31-
(see [#972](../../issues/972) and [#974](../../issues/974))
33+
### Infrastructure
34+
* replace `undefined` by own minimal implementation to avoid importing it
35+
(see [#981](../../discussions/981))
36+
3237

3338
## [Version 5.3.5](https://pypi.python.org/pypi/pyfakefs/5.3.5) (2024-01-30)
3439
Fixes a regression.

pyfakefs/pytest_tests/pytest_fixture_test.py

+3-4
Original file line numberDiff line numberDiff line change
@@ -13,10 +13,10 @@
1313
# Example for a test using a custom pytest fixture with an argument to Patcher
1414

1515
import pytest
16-
import undefined
1716

1817
import pyfakefs.pytest_tests.example as example
1918
from pyfakefs.fake_filesystem_unittest import Patcher
19+
from pyfakefs.pytest_tests import unhashable
2020

2121

2222
@pytest.mark.xfail
@@ -42,10 +42,9 @@ def test_example_file_passing_using_patcher():
4242
check_that_example_file_is_in_fake_fs()
4343

4444

45-
def test_undefined(fs):
45+
def test_unhashable(fs):
4646
# regression test for #923
47-
with pytest.raises(NotImplementedError):
48-
print(undefined)
47+
print(unhashable)
4948

5049

5150
def check_that_example_file_is_in_fake_fs():

pyfakefs/pytest_tests/pytest_reload_pandas_test.py

+8
Original file line numberDiff line numberDiff line change
@@ -5,14 +5,22 @@
55
from pathlib import Path
66

77
import pandas as pd
8+
import pytest
89

10+
try:
11+
import parquet
12+
except ImportError:
13+
parquet = None
914

15+
16+
@pytest.mark.skipif(parquet is None, reason="parquet not installed")
1017
def test_1(fs):
1118
dir_ = Path(__file__).parent / "data"
1219
fs.add_real_directory(dir_)
1320
pd.read_parquet(dir_ / "test.parquet")
1421

1522

23+
@pytest.mark.skipif(parquet is None, reason="parquet not installed")
1624
def test_2():
1725
dir_ = Path(__file__).parent / "data"
1826
pd.read_parquet(dir_ / "test.parquet")

pyfakefs/pytest_tests/unhashable.py

+19
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
import sys
2+
import types
3+
4+
5+
class Unhashable(types.ModuleType):
6+
"""
7+
Unhashable module, used for regression test for #923.
8+
"""
9+
10+
@property
11+
def Unhashable(self):
12+
return self
13+
14+
def __eq__(self, other):
15+
raise NotImplementedError("Cannot compare unhashable")
16+
17+
18+
if sys.modules[__name__] is not Unhashable:
19+
sys.modules[__name__] = Unhashable("unhashable")

0 commit comments

Comments
 (0)