Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Running a full test class fails when each test succeeds #900

Open
JonathanDCohen opened this issue Oct 24, 2023 · 10 comments
Open

Running a full test class fails when each test succeeds #900

JonathanDCohen opened this issue Oct 24, 2023 · 10 comments

Comments

@JonathanDCohen
Copy link

Describe the bug
There is a strange interaction going on between OpenPyxl and Pyfakefs via Pandas. I can read and write DataFrames as normal using the fake filesystem and pd.read_excel et al just fine when the tests are run in isolation. However, when I run the entire test class, one test will succeed and the rest will fail.

I have already used the solution in #716 to remove the use of LXML to read and write the Excel files.

How To Reproduce

import os
os.environ['OPENPYXL_LXML'] = 'False'
import io

import pandas as pd
from pyfakefs.fake_filesystem_unittest import TestCase

class BugTest(TestCase):
  def setUp(self) -> None:
    self.setUpPyfakefs()

  def test_a(self):
    df = pd.DataFrame({})
    df.to_excel('/testa.xlsx', index=False)

  def test_b(self):
    df = pd.DataFrame({})
    df.to_excel('/testb.xlsx', index=False)

  def test_c(self):
    df = pd.DataFrame({})
    df.to_excel('/testc.xlsx', index=False)

test_a passes, test_b and test_c fail with essentially the same output:

./test_src_load_research_population_data_prep.py::BugTest::test_b Failed with Error: [Errno 2] No such file or directory in the fake filesystem: '/tmp/openpyxl.ui35n6ko'
  File "/home/jcohen/.conda/env/lib/python3.8/site-packages/pyfakefs/fake_filesystem.py", line 2025, in remove_object
    target_directory.remove_entry(basename)
  File "/home/jcohen/.conda/env/lib/python3.8/site-packages/pyfakefs/fake_file.py", line 568, in remove_entry
    entry = self.get_entry(pathname_name)
  File "/home/jcohen/.conda/env/lib/python3.8/site-packages/pyfakefs/fake_file.py", line 542, in get_entry
    return self.entries[to_string(pathname_name)]
KeyError: 'openpyxl.ui35n6ko'
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
  File "/home/jcohen/.conda/env/lib/python3.8/unittest/case.py", line 60, in testPartExecutor
    yield
  File "/home/jcohen/.conda/env/lib/python3.8/unittest/case.py", line 676, in run
    self._callTestMethod(testMethod)
  File "/home/jcohen/.conda/env/lib/python3.8/unittest/case.py", line 633, in _callTestMethod
    method()
  File "/home/jcohen/pge-derp-model/test/test_src_load_research_population_data_prep.py", line 22, in test_b
    df.to_excel('/testb.xlsx', index=False)
  File "/home/jcohen/.local/lib/python3.8/site-packages/pandas/core/generic.py", line 2357, in to_excel
    formatter.write(
  File "/home/jcohen/.local/lib/python3.8/site-packages/pandas/io/formats/excel.py", line 902, in write
    writer.close()
  File "/home/jcohen/.local/lib/python3.8/site-packages/pandas/io/excel/_base.py", line 1205, in close
    self.save()
  File "/home/jcohen/.local/lib/python3.8/site-packages/pandas/io/excel/_openpyxl.py", line 81, in save
    self.book.save(self.handles.handle)
  File "/home/jcohen/.conda/env/lib/python3.8/site-packages/openpyxl/workbook/workbook.py", line 407, in save
    save_workbook(self, filename)
  File "/home/jcohen/.conda/env/lib/python3.8/site-packages/openpyxl/writer/excel.py", line 293, in save_workbook
    writer.save()
  File "/home/jcohen/.conda/env/lib/python3.8/site-packages/openpyxl/writer/excel.py", line 275, in save
    self.write_data()
  File "/home/jcohen/.conda/env/lib/python3.8/site-packages/openpyxl/writer/excel.py", line 75, in write_data
    self._write_worksheets()
  File "/home/jcohen/.conda/env/lib/python3.8/site-packages/openpyxl/writer/excel.py", line 215, in _write_worksheets
    self.write_worksheet(ws)
  File "/home/jcohen/.conda/env/lib/python3.8/site-packages/openpyxl/writer/excel.py", line 205, in write_worksheet
    writer.cleanup()
  File "openpyxl/worksheet/_writer.py", line 389, in openpyxl.worksheet._writer.WorksheetWriter.cleanup
  File "/home/jcohen/.conda/env/lib/python3.8/site-packages/pyfakefs/fake_os.py", line 691, in remove
    self.filesystem.remove(path)
  File "/home/jcohen/.conda/env/lib/python3.8/site-packages/pyfakefs/fake_filesystem.py", line 2889, in remove
    self.remove_object(norm_path)
  File "/home/jcohen/.conda/env/lib/python3.8/site-packages/pyfakefs/fake_filesystem.py", line 2027, in remove_object
    self.raise_os_error(errno.ENOENT, file_path)
  File "/home/jcohen/.conda/env/lib/python3.8/site-packages/pyfakefs/fake_filesystem.py", line 429, in raise_os_error
    raise OSError(err_no, message, filename)
FileNotFoundError: [Errno 2] No such file or directory in the fake filesystem: '/tmp/openpyxl.ui35n6ko'

Your environment
Please run the following in the environment where the problem happened and
paste the output.

python -c "import platform; print(platform.platform())"
Linux-5.15.0-1042-azure-x86_64-with-glibc2.17

python -c "import sys; print('Python', sys.version)"
Python 3.8.18 (default, Sep 11 2023, 13:20:55) 
[GCC 11.2.0]

python -c "from pyfakefs import __version__; print('pyfakefs', __version__)"
pyfakefs 5.3.0

conda list
# Name                    Version                   Build  Channel
_libgcc_mutex             0.1                 conda_forge    conda-forge
_openmp_mutex             4.5                       2_gnu    conda-forge
abseil-cpp                20210324.2           h2531618_0    anaconda
aiofiles                  22.1.0           py38h06a4308_0    anaconda
aiohttp                   3.8.5            py38h5eee18b_0    anaconda
aiohttp-retry             2.8.3              pyhd8ed1ab_0    conda-forge
aiosignal                 1.2.0              pyhd3eb1b0_0    anaconda
aiosqlite                 0.18.0           py38h06a4308_0    anaconda
anyio                     3.5.0            py38h06a4308_0    anaconda
argon2-cffi               21.3.0             pyhd3eb1b0_0    anaconda
argon2-cffi-bindings      21.2.0           py38h7f8727e_0    anaconda
arrow-cpp                 1.0.1           py38hdfa91af_57_cpu    conda-forge
asttokens                 2.0.5              pyhd3eb1b0_0    anaconda
async-timeout             4.0.2            py38h06a4308_0    anaconda
attrs                     23.1.0           py38h06a4308_0    anaconda
aws-c-auth                0.6.5                h00e28c2_5    conda-forge
aws-c-cal                 0.5.12               h8c99da7_6    conda-forge
aws-c-common              0.6.16               h7f98852_0    conda-forge
aws-c-compression         0.2.14               h4f5cfdb_6    conda-forge
aws-c-event-stream        0.2.7               hedd7935_30    conda-forge
aws-c-http                0.6.10               he2927c9_1    conda-forge
aws-c-io                  0.10.13              h4e1a65d_2    conda-forge
aws-c-mqtt                0.7.8                h1e34fcd_9    conda-forge
aws-c-s3                  0.1.27               hbe77d09_8    conda-forge
aws-c-sdkutils            0.1.1                h4f5cfdb_3    conda-forge
aws-checksums             0.1.12               h4f5cfdb_5    conda-forge
aws-crt-cpp               0.17.4               ha10c5ac_2    conda-forge
aws-sdk-cpp               1.9.140              h94f6c54_1    conda-forge
azure-core                1.27.1           py38h06a4308_0    anaconda
azure-storage-blob        12.16.0            pyhd8ed1ab_1    conda-forge
babel                     2.11.0           py38h06a4308_0    anaconda
backcall                  0.2.0              pyhd3eb1b0_0    anaconda
beautifulsoup4            4.12.2           py38h06a4308_0    anaconda
blas                      1.0                         mkl    anaconda
bleach                    4.1.0              pyhd3eb1b0_0    anaconda
bokeh                     2.4.3            py38h06a4308_0    anaconda
boost-cpp                 1.82.0               hdb19cb5_2    anaconda
bottleneck                1.3.5            py38h7deecbd_0    anaconda
brotli                    1.0.9                h5eee18b_7    anaconda
brotli-bin                1.0.9                h5eee18b_7    anaconda
brotlipy                  0.7.0           py38h27cfd23_1003    anaconda
bzip2                     1.0.8                h7b6447c_0    anaconda
c-ares                    1.19.1               h5eee18b_0    anaconda
ca-certificates           2023.08.22           h06a4308_0    anaconda
certifi                   2023.7.22        py38h06a4308_0    anaconda
cffi                      1.15.1           py38h5eee18b_3    anaconda
charset-normalizer        2.0.4              pyhd3eb1b0_0    anaconda
click                     8.1.7                    pypi_0    pypi
colorama                  0.4.6            py38h06a4308_0    anaconda
colorcet                  3.0.1            py38h06a4308_0    anaconda
comm                      0.1.2            py38h06a4308_0    anaconda
configparser              5.0.1                      py_0    anaconda
contourpy                 1.0.5            py38hdb19cb5_0    anaconda
cramjam                   2.6.2            py38h52d8a92_0    anaconda
cryptography              41.0.3           py38h130f0dd_0    anaconda
cycler                    0.11.0             pyhd3eb1b0_0    anaconda
dbus                      1.13.18              hb2f20db_0    anaconda
debugpy                   1.6.7            py38h6a678d5_0    anaconda
decorator                 4.4.2              pyhd3eb1b0_0    anaconda
defusedxml                0.7.1              pyhd3eb1b0_0    anaconda
dill                      0.3.3                    pypi_0    pypi
duckdb                    0.8.1                    pypi_0    pypi
eemeter                   2.10.11                  pypi_0    pypi
eeweather                 0.3.24                   pypi_0    pypi
entrypoints               0.4              py38h06a4308_0    anaconda
et_xmlfile                1.1.0            py38h06a4308_0    anaconda
executing                 0.8.3              pyhd3eb1b0_0    anaconda
expat                     2.5.0                h6a678d5_0    anaconda
fastparquet               2023.4.0         py38ha9d4c09_0    anaconda
fonttools                 4.25.0             pyhd3eb1b0_0    anaconda
freetype                  2.12.1               h4a9f257_0    anaconda
frozenlist                1.3.3            py38h5eee18b_0    anaconda
fsspec                    2023.9.2         py38h06a4308_0    anaconda
gflags                    2.2.2                he6710b0_0    anaconda
giflib                    5.2.1                h5eee18b_3    anaconda
gitdb                     4.0.7              pyhd3eb1b0_0    anaconda
gitpython                 3.1.37           py38h06a4308_0    anaconda
glib                      2.69.1               he621ea3_2    anaconda
glog                      0.5.0                h2531618_0    anaconda
greenlet                  2.0.1            py38h6a678d5_0    anaconda
grpc-cpp                  1.41.1               h75e9d12_2    conda-forge
h11                       0.14.0             pyhd8ed1ab_0    conda-forge
h2                        4.0.0            py38h06a4308_3    anaconda
holoviews                 1.14.8             pyhd3eb1b0_0    anaconda
hpack                     4.0.0                      py_0    anaconda
httpcore                  0.18.0             pyhd8ed1ab_0    conda-forge
httpx                     0.25.0             pyhd8ed1ab_0    conda-forge
hvplot                    0.6.0                      py_1    anaconda
hyperframe                6.0.1              pyhd3eb1b0_0    anaconda
icu                       73.1                 h6a678d5_0    anaconda
idna                      3.4              py38h06a4308_0    anaconda
importlib-metadata        6.0.0            py38h06a4308_0    anaconda
importlib_metadata        6.0.0                hd3eb1b0_0    anaconda
importlib_resources       5.2.0              pyhd3eb1b0_1    anaconda
intel-openmp              2023.1.0         hdb19cb5_46305    anaconda
ipykernel                 6.25.0           py38h2f386ee_0    anaconda
ipython                   8.12.2           py38h06a4308_0    anaconda
ipython_genutils          0.2.0              pyhd3eb1b0_1    anaconda
isodate                   0.6.1            py38h06a4308_0    anaconda
jaraco.classes            3.2.1              pyhd3eb1b0_0    anaconda
jedi                      0.18.1           py38h06a4308_1    anaconda
jeepney                   0.7.1              pyhd3eb1b0_0    anaconda
jinja2                    3.0.3              pyhd3eb1b0_0    anaconda
jpeg                      9e                   h5eee18b_1    anaconda
json5                     0.9.6              pyhd3eb1b0_0    anaconda
jsonschema                4.17.3           py38h06a4308_0    anaconda
jupyter-server-mathjax    0.2.6              pyh5bfe37b_1    conda-forge
jupyter_client            8.1.0            py38h06a4308_0    anaconda
jupyter_core              5.3.0            py38h06a4308_0    anaconda
jupyter_events            0.6.3            py38h06a4308_0    anaconda
jupyter_server            2.5.0            py38h06a4308_0    anaconda
jupyter_server_fileid     0.9.0            py38h06a4308_0    anaconda
jupyter_server_terminals  0.4.4            py38h06a4308_1    anaconda
jupyter_server_ydoc       0.8.0            py38h06a4308_1    anaconda
jupyter_ydoc              0.2.4            py38h06a4308_0    anaconda
jupyterlab                3.6.3            py38h06a4308_0    anaconda
jupyterlab-git            0.43.0             pyhd8ed1ab_0    conda-forge
jupyterlab_pygments       0.1.2                      py_0    anaconda
jupyterlab_server         2.22.0           py38h06a4308_0    anaconda
keyring                   23.13.1          py38h06a4308_0    anaconda
kiwisolver                1.4.4            py38h6a678d5_0    anaconda
knockknock                0.1.8.1                    py_0    conda-forge
krb5                      1.20.1               h568e23c_1    anaconda
lcms2                     2.12                 h3be6417_0    anaconda
ld_impl_linux-64          2.38                 h1181459_1    anaconda
lerc                      3.0                  h295c915_0    anaconda
libboost                  1.82.0               h109eef0_2    anaconda
libbrotlicommon           1.0.9                h5eee18b_7    anaconda
libbrotlidec              1.0.9                h5eee18b_7    anaconda
libbrotlienc              1.0.9                h5eee18b_7    anaconda
libcurl                   8.2.1                h91b91d3_0    anaconda
libdeflate                1.17                 h5eee18b_1    anaconda
libedit                   3.1.20221030         h5eee18b_0    anaconda
libev                     4.33                 h7f8727e_1    anaconda
libevent                  2.1.12               h8f2d780_0    anaconda
libffi                    3.4.4                h6a678d5_0    anaconda
libgcc                    7.2.0                h69d50b8_2    anaconda
libgcc-ng                 13.2.0               h807b86a_2    conda-forge
libgomp                   13.2.0               h807b86a_2    conda-forge
libnghttp2                1.52.0               ha637b67_1    anaconda
libpng                    1.6.39               h5eee18b_0    anaconda
libprotobuf               3.18.1               h780b84a_0    conda-forge
libsodium                 1.0.18               h7b6447c_0    anaconda
libssh2                   1.10.0               h37d81fd_2    anaconda
libstdcxx-ng              11.2.0               h1234567_1    anaconda
libthrift                 0.15.0               h0d84882_2    anaconda
libtiff                   4.5.1                h6a678d5_0    anaconda
libutf8proc               2.6.1                h5eee18b_1    anaconda
libwebp                   1.3.2                h11a3e52_0    anaconda
libwebp-base              1.3.2                h5eee18b_0    anaconda
libxml2                   2.10.4               hf1b16e4_1    anaconda
libxslt                   1.1.37               h5eee18b_1    anaconda
libzlib                   1.2.13               hd590300_5    conda-forge
lxml                      4.9.3            py38hdbbb534_0    anaconda
lz4-c                     1.9.3                h295c915_1    anaconda
markdown                  3.4.1            py38h06a4308_0    anaconda
markupsafe                2.1.1            py38h7f8727e_0    anaconda
matplotlib-base           3.7.2            py38h1128e8f_0    anaconda
matplotlib-inline         0.1.6            py38h06a4308_0    anaconda
matrix_client             0.4.0              pyhd8ed1ab_0    conda-forge
mistune                   0.8.4           py38h7b6447c_1000    anaconda
mkl                       2023.1.0         h213fc3f_46343    anaconda
mkl-service               2.4.0            py38h5eee18b_1    anaconda
mkl_fft                   1.3.8            py38h5eee18b_0    anaconda
mkl_random                1.2.4            py38hdb19cb5_0    anaconda
more-itertools            8.12.0             pyhd3eb1b0_0    anaconda
multidict                 6.0.2            py38h5eee18b_0    anaconda
munkres                   1.1.4                      py_0    anaconda
nbclassic                 0.5.5            py38h06a4308_0    anaconda
nbclient                  0.5.13           py38h06a4308_0    anaconda
nbconvert                 6.5.4            py38h06a4308_0    anaconda
nbdime                    3.2.1              pyhd8ed1ab_0    conda-forge
nbformat                  5.9.2            py38h06a4308_0    anaconda
ncurses                   6.4                  h6a678d5_0    anaconda
nest-asyncio              1.5.6            py38h06a4308_0    anaconda
nodejs                    6.13.1                        0    conda-forge
notebook                  6.5.4            py38h06a4308_0    anaconda
notebook-shim             0.2.2            py38h06a4308_0    anaconda
numexpr                   2.8.4            py38hc78ab66_1    anaconda
numpy                     1.24.4                   pypi_0    pypi
openjpeg                  2.4.0                h3ad879b_0    anaconda
openpyxl                  3.0.10           py38h5eee18b_0    anaconda
openssl                   1.1.1w               h7f8727e_0    anaconda
orc                       1.7.1                h68e2c4e_0    conda-forge
packaging                 23.1             py38h06a4308_0    anaconda
pandarallel               1.6.4            py38h06a4308_0    anaconda
pandas-bokeh              0.5                      pypi_0    pypi
pandocfilters             1.5.0              pyhd3eb1b0_0    anaconda
panel                     0.9.7                      py_0    anaconda
param                     1.9.3                      py_0    anaconda
parquet-cpp               1.5.1                h34088ae_4    anaconda
parso                     0.8.3              pyhd3eb1b0_0    anaconda
patsy                     0.5.3                    pypi_0    pypi
pcre                      8.45                 h295c915_0    anaconda
pexpect                   4.8.0              pyhd3eb1b0_3    anaconda
pickleshare               0.7.5           pyhd3eb1b0_1003    anaconda
pillow                    10.0.1           py38ha6cbd5a_0    anaconda
pip                       22.3.1           py38h06a4308_0    anaconda
pkgutil-resolve-name      1.3.10           py38h06a4308_0    anaconda
platformdirs              3.10.0           py38h06a4308_0    anaconda
plotly                    4.11.0                     py_0    anaconda
prometheus_client         0.14.1           py38h06a4308_0    anaconda
prompt-toolkit            3.0.36           py38h06a4308_0    anaconda
psutil                    5.9.0            py38h5eee18b_0    anaconda
ptyprocess                0.7.0              pyhd3eb1b0_2    anaconda
pure_eval                 0.2.2              pyhd3eb1b0_0    anaconda
pyarrow                   1.0.1           py38he7e5f7d_57_cpu    conda-forge
pycparser                 2.21               pyhd3eb1b0_0    anaconda
pyct                      0.5.0            py38h06a4308_0    anaconda
pyfakefs                  5.3.0              pyhd8ed1ab_0    conda-forge
pygments                  2.15.1           py38h06a4308_1    anaconda
pyinstrument              4.5.0            py38h01eb140_0    conda-forge
pyjwt                     2.4.0            py38h06a4308_0    anaconda
pyopenssl                 23.2.0           py38h06a4308_0    anaconda
pyparsing                 3.0.9            py38h06a4308_0    anaconda
pyproj                    3.5.0                    pypi_0    pypi
pyrsistent                0.18.0           py38heee7806_0    anaconda
pysocks                   1.7.1            py38h06a4308_0    anaconda
python                    3.8.18               h7a1cb2a_0    anaconda
python-dateutil           2.8.2              pyhd3eb1b0_0    anaconda
python-fastjsonschema     2.16.2           py38h06a4308_0    anaconda
python-json-logger        2.0.7            py38h06a4308_0    anaconda
python-telegram-bot       20.6               pyhd8ed1ab_0    conda-forge
python-tzdata             2022.1             pyhd8ed1ab_0    conda-forge
python_abi                3.8                      2_cp38    conda-forge
pytz                      2020.4                   pypi_0    pypi
pyviz_comms               0.7.6                      py_0    anaconda
pyyaml                    5.3.1            py38h7b6447c_1    anaconda
pyzmq                     25.1.0           py38h6a678d5_0    anaconda
re2                       2021.11.01           h9c3ff4c_0    conda-forge
readline                  8.2                  h5eee18b_0    anaconda
requests                  2.31.0           py38h06a4308_0    anaconda
retrying                  1.3.3              pyhd3eb1b0_2    anaconda
rfc3339-validator         0.1.4            py38h06a4308_0    anaconda
rfc3986-validator         0.1.1            py38h06a4308_0    anaconda
s2n                       1.2.0                h9b69904_0    conda-forge
scipy                     1.5.4                    pypi_0    pypi
secretstorage             3.3.1            py38h06a4308_1    anaconda
send2trash                1.8.0              pyhd3eb1b0_1    anaconda
setuptools                68.0.0           py38h06a4308_0    anaconda
shapely                   1.7.1                    pypi_0    pypi
six                       1.16.0             pyhd3eb1b0_1    anaconda
smmap                     4.0.0              pyhd3eb1b0_0    anaconda
snappy                    1.1.9                h295c915_0    anaconda
sniffio                   1.2.0            py38h06a4308_1    anaconda
soupsieve                 2.5              py38h06a4308_0    anaconda
sqlalchemy                1.4.39           py38h5eee18b_0    anaconda
sqlite                    3.41.2               h5eee18b_0    anaconda
stack_data                0.2.0              pyhd3eb1b0_0    anaconda
statsmodels               0.14.0                   pypi_0    pypi
tbb                       2021.8.0             hdb19cb5_0    anaconda
terminado                 0.17.1           py38h06a4308_0    anaconda
tinycss2                  1.2.1            py38h06a4308_0    anaconda
tk                        8.6.12               h1ccaba5_0    anaconda
tomli                     2.0.1            py38h06a4308_0    anaconda
tornado                   6.3.3            py38h5eee18b_0    anaconda
tqdm                      4.65.0           py38hb070fc8_0    anaconda
traitlets                 5.7.1            py38h06a4308_0    anaconda
twilio                    8.10.0             pyhd8ed1ab_0    conda-forge
typing-extensions         4.7.1            py38h06a4308_0    anaconda
typing_extensions         4.7.1            py38h06a4308_0    anaconda
urllib3                   1.26.16          py38h06a4308_0    anaconda
wcwidth                   0.2.5              pyhd3eb1b0_0    anaconda
webencodings              0.5.1                    py38_1    anaconda
websocket-client          0.58.0           py38h06a4308_4    anaconda
wheel                     0.41.2           py38h06a4308_0    anaconda
xz                        5.4.2                h5eee18b_0    anaconda
y-py                      0.5.9            py38h52d8a92_0    anaconda
yagmail                   0.15.293           pyhd8ed1ab_0    conda-forge
yaml                      0.2.5                h7b6447c_0    anaconda
yarl                      1.8.1            py38h5eee18b_0    anaconda
ypy-websocket             0.8.2            py38h06a4308_0    anaconda
zeromq                    4.3.4                h2531618_0    anaconda
zipp                      3.11.0           py38h06a4308_0    anaconda
zlib                      1.2.13               hd590300_5    conda-forge
zstd                      1.5.2                ha4553b6_0    anaconda
@mrbean-bremen
Copy link
Member

Thanks for the report!
I could not reproduce this under Windows (where I work at the moment), so I guess there is some Posix-specific code involved.
It may also be that is is version-specific. In your conda list, there is no pandas listed - didn't you install it via conda? Which version did you use?

@JonathanDCohen
Copy link
Author

We're on pandas 1.5.3. It's installed through pip for some reason, although I don't know why.

@mrbean-bremen
Copy link
Member

Thanks - downgrading to 1.5.3 didn't change the outcome. I will have a closer look somewhere in the next days.

@JonathanDCohen
Copy link
Author

Thanks for taking a look! Let me know how else I can help.

@mrbean-bremen
Copy link
Member

I still cannot reproduce the problem. I tested your example in the CI, and it runs fine in Ubuntu, MacOS and Windows, under Python 3.8 to 3.12.
I had installed pandas 1.5.3 and openpyxl 3.0.10, and ran it using pytest (how are you running the test?).

The environment is not the same, as I used a different Linux, the packages had been installed via pip instead of conda, and I did not install the bunch of other packages in your environment, but none of these should make a difference, so I'm a bit lost...
I can see from the stacktrace that some temp file in the second test is not in the fake filesystem, so it had likely been created in the real filesystem and the patching did not work at some point, but at the moment I have no idea why.

As long as I'm not able to reproduce this I cannot promise any fix. I will let you know if I can think of some additional tests you can do to clarify this.

@mrbean-bremen
Copy link
Member

@JonathanDCohen - I have tried a couple of times to reproduce or understand this, but without success.
Is this still a problem for you? If yes, could you reproduce this on any other system?

@JonathanDCohen
Copy link
Author

I'll see if I can't make a small reproduction

@mrbean-bremen
Copy link
Member

mrbean-bremen commented Mar 7, 2024

I had recently a number of issues related to the dynamic patcher cleanup.
You could check if your problem is also related to this by switching off the dynamic patcher:

  def setUp(self) -> None:
      self.setUpPyfakefs(use_dynamic_patch=False)

You need to update pyfakefs to the latest version for this, as this option was not available in the version you used.
If either all tests pass, or no test passes, the problem is indeed related to the dynamic patcher.

@JonathanDCohen
Copy link
Author

JonathanDCohen commented Mar 7, 2024 via email

@mrbean-bremen
Copy link
Member

I just published a new release - please use this if you are going to re-test the problem.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants