Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions CHANGES.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@ The released versions correspond to PyPI releases.
compatible, we cannot exclude that we missed some problems.
* Under macOS, at test start a symlink `/tmp` to the actual temporary directory is
now created in the fake filesystem.
* Patching of parsers for pandas >= 1.2 is removed since pandas now uses Python fs functions
internally even when the engine selected is "c".

### Features
* added possibility to set a path inaccessible under Windows by using `chown()` with
Expand Down
15 changes: 12 additions & 3 deletions pyfakefs/patched_packages.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
import sys

try:
import pandas as pd
import pandas.io.parsers as parsers
except ImportError:
parsers = None
Expand All @@ -31,6 +32,14 @@
except ImportError:
locks = None

# From pandas v 1.2 onwards the python fs functions are used even when the engine
# selected is "c". This means that we don't explicitly have to change the engine.
patch_pandas = parsers is not None and [int(v) for v in pd.__version__.split(".")] < [
1,
2,
0,
]


def get_modules_to_patch():
modules_to_patch = {}
Expand All @@ -43,14 +52,14 @@ def get_modules_to_patch():

def get_classes_to_patch():
classes_to_patch = {}
if parsers is not None:
if patch_pandas:
classes_to_patch["TextFileReader"] = "pandas.io.parsers"
return classes_to_patch


def get_fake_module_classes():
fake_module_classes = {}
if parsers is not None:
if patch_pandas:
fake_module_classes["TextFileReader"] = FakeTextFileReader
return fake_module_classes

Expand Down Expand Up @@ -94,7 +103,7 @@ def __getattr__(self, name):
return getattr(self._xlrd_module, name)


if parsers is not None:
if patch_pandas:
# we currently need to add fake modules for both the parser module and
# the contained text reader - maybe this can be simplified

Expand Down