Skip to content

Commit

Permalink
Remove the need to import the "undefined" module in test
Browse files Browse the repository at this point in the history
- the module is not maintained and very trivial
  • Loading branch information
mrbean-bremen committed Mar 15, 2024
1 parent 816d114 commit 3c5db6c
Show file tree
Hide file tree
Showing 5 changed files with 39 additions and 8 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/testsuite.yml
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ jobs:
run: |
pip install -r requirements.txt
pip install -U pytest==${{ matrix.pytest-version }}
pip install opentimelineio undefined pandas parquet pyarrow
pip install opentimelineio pandas parquet pyarrow
pip install -e .
if [[ '${{ matrix.pytest-version }}' == '4.0.2' ]]; then
pip install -U attrs==19.1.0
Expand Down
11 changes: 8 additions & 3 deletions CHANGES.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,10 @@ The released versions correspond to PyPI releases.
* removed the argument `module_cleanup_mode`, that was introduced as a temporary workaround
in the previous version - related problems shall be handled using a cleanup handler

### Enhancements
* added support for `O_NOFOLLOW` and `O_DIRECTORY` flags in `os.open`
(see [#972](../../issues/972) and [#974](../../issues/974))

### Fixes
* fixed a specific problem on reloading a pandas-related module (see [#947](../../issues/947)),
added possibility for unload hooks for specific modules
Expand All @@ -26,9 +30,10 @@ The released versions correspond to PyPI releases.
* fixed permission problem with `shutil.rmtree` if emulating Windows under POSIX
(see [#979](../../issues/979))

### Enhancements
* added support for `O_NOFOLLOW` and `O_DIRECTORY` flags in `os.open`
(see [#972](../../issues/972) and [#974](../../issues/974))
### Infrastructure
* replace `undefined` by own minimal implementation to avoid importing it
(see [#981](../../discussions/981))


## [Version 5.3.5](https://pypi.python.org/pypi/pyfakefs/5.3.5) (2024-01-30)
Fixes a regression.
Expand Down
7 changes: 3 additions & 4 deletions pyfakefs/pytest_tests/pytest_fixture_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,10 @@
# Example for a test using a custom pytest fixture with an argument to Patcher

import pytest
import undefined

import pyfakefs.pytest_tests.example as example
from pyfakefs.fake_filesystem_unittest import Patcher
from pyfakefs.pytest_tests import unhashable


@pytest.mark.xfail
Expand All @@ -42,10 +42,9 @@ def test_example_file_passing_using_patcher():
check_that_example_file_is_in_fake_fs()


def test_undefined(fs):
def test_unhashable(fs):
# regression test for #923
with pytest.raises(NotImplementedError):
print(undefined)
print(unhashable)


def check_that_example_file_is_in_fake_fs():
Expand Down
8 changes: 8 additions & 0 deletions pyfakefs/pytest_tests/pytest_reload_pandas_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,22 @@
from pathlib import Path

import pandas as pd
import pytest

try:
import parquet
except ImportError:
parquet = None


@pytest.mark.skipif(parquet is None, reason="parquet not installed")
def test_1(fs):
dir_ = Path(__file__).parent / "data"
fs.add_real_directory(dir_)
pd.read_parquet(dir_ / "test.parquet")


@pytest.mark.skipif(parquet is None, reason="parquet not installed")
def test_2():
dir_ = Path(__file__).parent / "data"
pd.read_parquet(dir_ / "test.parquet")
19 changes: 19 additions & 0 deletions pyfakefs/pytest_tests/unhashable.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
import sys
import types


class Unhashable(types.ModuleType):
"""
Unhashable module, used for regression test for #923.
"""

@property
def Unhashable(self):
return self

def __eq__(self, other):
raise NotImplementedError("Cannot compare unhashable")


if sys.modules[__name__] is not Unhashable:
sys.modules[__name__] = Unhashable("unhashable")

0 comments on commit 3c5db6c

Please sign in to comment.