-
Notifications
You must be signed in to change notification settings - Fork 91
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
Plans to support io.open_code
?
#554
Comments
Thanks for the report! I hadn't seen |
Yes, that's correct--I am using Thanks for the quick response! |
Hm, that turns out to be a bit more complicated than I thought. If I fake |
- added new argument 'patch_open_code' to allow patching the function - see pytest-dev#554
- added new argument 'patch_open_code' to allow patching the function - see pytest-dev#554
@shoshber - I added a new argument patch_open_code that by default is set to |
Indeed--in fact it breaks mine 🤣 I should have seen that coming--the code under test uses |
I'm confused--your example works for me without patching, but fails if |
Color me confused as well. I think this example explains it better: example.zip. Here is how I run the example:
If I understand what you're saying, that describes my situation most closely. Again, thank you for your help! If this isn't feasible, I understand and can find an alternative. |
Thanks - didn't get to it today, but I will have a look tomorrow. Maybe I'll get an idea... |
Ok, I changed the argument to now take an enum ( |
It works beautifully, thank you! This might be the most positive and pleasant experience I've ever had on an issue thread. |
Thanks 😄 -- always good to know we could help someone! We will probably make a new release soon, if nothing else comes up. |
Is your feature request related to a problem? Please describe.
In python 3.8.1+ my tests are failing because of this change: python/cpython#17244
This appears to be because pyfakefs' io only mocks
io.open
(http://jmcgeheeiv.github.io/pyfakefs/release/modules.html?highlight=io#pyfakefs.fake_filesystem.FakeIoModule)This is somewhat disappointing as pyfakefs has worked perfectly until now.
Describe the solution you'd like
pyfakefs supports
io.open_code
. Full disclosure: I have no idea how feasible this is. The implementation appears to be in C (https://github.com/python/cpython/blob/47a23fc63fa5df2da8dbc542e78e521d4a7f10c9/Modules/_io/_iomodule.c#L520) but there is this also this pure python implementation that usesopen()
, which apparently exists "for tests": https://github.com/python/cpython/blob/942f7a2dea2e95a0fa848329565c0d0288d92e47/Lib/_pyio.py#L259Describe alternatives you've considered
For now, I'm only testing with 3.8.0. For a more permanent solution, I could mock it by hand using the mock module. The easiest thing, however, would be to rework the tests so that they use the actual file system.
The text was updated successfully, but these errors were encountered: