Running a sudo command in a fakefs reults in RecursionError #929
Replies: 3 comments
-
Without looking at the concrete problem I suspect that this is due to a limitation in pyfakefs with modules using the C file interface, specifically subprocess is known to not play nice with pyfakefs. |
Beta Was this translation helpful? Give feedback.
-
Yes, I have seen these errors with subprocess in unit tests. In those tests, I have also had to mock.patch.object the subprocess calls with the unittest.mock module. This worked well in those unit tests, since pyfakefs cannot provide its file system to the environment created by subprocess. |
Beta Was this translation helpful? Give feedback.
-
As I suspected and @davidlbaird mentioned, this will indeed not work with |
Beta Was this translation helpful? Give feedback.
-
Describe the bug
I am not sure if it is approachable what I am trying.
I have a function, I provided below, which allows sudo calls from inside my python module. I've tested this function multiple times in realfs without any issue. I am now at a point where I utilize the function to copy via
rsync
file inside the fakefs.This results in following recursion error:
How To Reproduce
This is my function which calls system sudo calls:
If I use this function inside a simple test scenario with pyfakefs the recursion error happens:
Your environment
Please run the following in the environment where the problem happened and
paste the output.
Linux-6.6.4-arch1-1-x86_64-with-glibc2.38
Python 3.11.6 (main, Nov 14 2023, 09:36:21) [GCC 13.2.1 20230801]
pyfakefs 5.3.0
pytest 7.4.3
Beta Was this translation helpful? Give feedback.
All reactions