-
Notifications
You must be signed in to change notification settings - Fork 87
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
Extract Patcher #519
Comments
Interesting idea, I haven't thought about this. @jmcgeheeiv - what do you think? |
Well, @petr-motejlek, that's just about the highest compliment we could receive. We are perhaps a bit blinkered by our focus on |
I have also thought about this a bit, and while I see the theoretical possibility to extract the patcher, I see no real use case at the moment. The Patcher alone is not sufficient - it also needs a fake implementation of the replaced module - at least this is the case in pyfakefs. Creating a fake module that simulates the real functionality (as opposed to a mock or stub) is not a trivial task. But if there is any use real case I will be happy to go ahead and split out the Patcher. This can be done first in the same package, and if needed, it can be moved into a separate package later. |
Let's compare the way your internal patcher works to
I think the extracted patcher should roughly work this way:
I think this way, you could even use it from within pyfakefs, or write pyfakefs in a way where I interface with both it and this patcher. Both are likely OK.
Wen it comes to the usability of such a Patcher. I think sky would then be the limit. Again, going back to other faking libraries (such as Cheers |
Thanks for that extensive explanation! You made your case, and "the sky is the limit" sounds good for a plan. 😀 I think I'm going to try to extract the patcher, and derive from it or configure it for pyfakefs, though this will take some time. If I succeed with that, @jmcgeheeiv can decide if he wants to split it into a separate package. |
It probably makes sense to do this after the 4.0 release. I was actually thinking about making a release soon (we promised one for the beginningof the year), with Python 2 support removed and a few bug fixes already there. |
Sounds great. Kudos for deciding to drop Python 2. It's time the world migrated away from it :). |
Getting back to this... I had played around with extracting
What I would omit (at least for the first version), are the I'm still not sure how useful that would be, but as have seen a lot of struggling to correctly use @jmcgeheeiv - what do you think? |
Perhaps enhance |
Yes, something like that. A |
Yeah, that sounds good! |
Hey,
I’ve recently used two other libraries that allow one to stub out certain standard library functions, and I used them together with pyfakefs and really big kudos on how simple it is to patch things with pyfakefs in comparison ;)
Hence my thought: would you consider extracting the Patcher functionality into a separate package such that it would be possible to use it when patching other modules as well, as that would lead to less wheel reinvention?
I especially like how it tries to deal with all potential caveats, including allowing the user to have their SUT reloaded as a last resort. None of the other patchers I’ve seen so far do this!
The text was updated successfully, but these errors were encountered: