[WIP] Make fake filesystem, fake `os` and fake `os.path` respect `additional_skip_names`
Describe the changes
Add a call stack check for fake filesystem, os and os.path methods in their handle_original_call wrapper to see if they are being called from a module listed in skip_modules.
Tasks
- [x] Unit tests added that reproduce the issue or prove feature is working
- [x] Fix or feature added
- [ ] Entry to release notes added
- [ ] Pre-commit CI shows no errors
- [x] Unit tests passing
- [x] For documentation changes: The Read the Docs preview builds and looks as expected
This is mostly brainstorm material to see if we want to go in this direction.
Implementation details:
Most of the job is done as a filter in wrapper functions, is_called_from_skipped_module starts from the end of the call stack and goes up until it reaches a module that is:
- Is not a frozen importlib
- outside of Python's stdlib
- outside of pyfakefs library itself (except for
tests/andpytest_tests/directories) This module is considered the module that is calling the wrapped function and if it is listed inskip_names, then it will try to run the original function instead of the fake wrapped function.
It is working for Python 3.12, 3.11 and mostly 3.10, but 3.9, 3.8 and 3.7 have yet different internals for pathlib.
@mrbean-bremen When you got the time, please check it and let me know if you approve this approach. If it looks good to you, I will work on tests for other Python versions and Windows.
@sassanh - are you still working on this, or have you given up?
I'm not actively working on it but I have it on my radar. If the open pull request is causing trouble in organization we can close it. The blocking issue is still updating the tests for older python versions. The thing is I don't know how much work is needed to address these issues.
The PR isn't blocking anything - I just wanted to know if you are still on it, or if you need help. Take all the time you need - and thanks for the effort!
Feel free to add any commits or make any changes to this pull request as needed. Your help is greatly appreciated! I might not have the capacity to address tests for older versions in the new future.
@sassanh - I've rebased against main and fixed the failing tests (disabled one test for PyPy 3.7, as I didn't want to invest time in that outdated version), but other than that, only the release notes are missing as far as I can see. Please check my commit and add the release notes (and anything you still want to add), and we can go and merge this.
@mrbean-bremen Thank you so much! I appreciate your help! I will check your commit and add the release notes in the weekend.
@mrbean-bremen I checked the changes and it all looks good to me. I added the release notes too. Let's merge it if it looks good to you.