Questions tagged [pyfakefs]

pyfakefs implements a fake file system that mocks the Python file system modules. If using pyfakefs, the tests operate on a fake file system in memory without touching the real disk. pyfakefs directly supports unittest and pytest, and can be used with other testing frameworks.

Reference:

20 questions
0
votes
0 answers

How to use pyfakefs, pytest to test a function using `multiprocessing.Queue` via a `Manager`?

I am trying to test a code that uses multiprocessing.Queue. I tried using the additional_skip_names, calling multiprocessing.freeze_support() and multiprocessing.set_start_method('forkserver'), but nothing seems to work. Here is a minimal…
Jorge E. Cardona
  • 92,161
  • 3
  • 37
  • 44
0
votes
1 answer

pyfakefs fixture causes pandas.read_csv() to fail in pytest

I am using pandas read_csv() function to read some CSV content and want to use "high" or "round_trip" floating-point precision. The following works in the Python REPL or running a program with the python interpreter dircectly. import pandas as…
0
votes
1 answer

patch_default_args is True but PyFakeFS don't patch pathlib.Path.cwd()

I use pathlib.Path.cwd() as a default argument in a function signature. def foobar(dir_arg=pathlib.Path.cwd() / 'logs'): # ... When I unittest this function with pyfakefs the argument isn't patched. But the patch_default_args is set to…
buhtz
  • 10,774
  • 18
  • 76
  • 149
0
votes
1 answer

Testing isinstance(PosixPath) using pytest with pyfakefs

In my code, I test if config_location is an instance of PosixPath or None: if isinstance(self.config_location, (PosixPath, type(None))): ... This works fine when run with the normal python interpreter, but fails during my pytest tests using…
0
votes
0 answers

Maintaining two pyfakefs file systems in pytest with additional files

I'm trying to write unit tests using pytest for a configuration system that should look in a couple of different places for config files. I can use pyfakefs via the fs plugin to create a fixture that provides a set of files, including a config file…
David_O
  • 1,143
  • 7
  • 16
1
2