magic handling of mock.patch() is confusing and not generic enough.
See original GitHub issueOkay, so I’m raising this as a result of:
https://github.com/Simplistix/testfixtures/issues/65
testfixtures’ log_capture()
(and a couple of other decorators it offers) use the same pattern as mock.patch
as implemented here:
However, I see that mock.patch
only works because of the magical handling here:
This means that end users and library developers are confused when one works and not the other does not. Not sure I have any good suggestions, just wanted to vent over the hours I’ve wasted on this…
Issue Analytics
- State:
- Created 6 years ago
- Comments:25 (15 by maintainers)
Top Results From Across the Web
Why python mock patch doesn't work? - Stack Overflow
When I run python test_spike.py , the first test case would pass, but the second would fail. and I switch to use nosetests...
Read more >unittest.mock — mock object library — Python 3.11.1 ...
The Mock classes have support for mocking magic methods. See magic methods for the full details. The mock classes and the patch() decorators...
Read more >pytest should use the inspect.signature algorithm to determine ...
pytest 3.0.6 on python 3.6, Arch Linux (distro packages). ... magic handling of mock.patch() is confusing and not generic enough. #2828.
Read more >Using Mocks to Test External Dependencies or Reduce ...
We mock out the send_mail function again using the patch decorator, but this time we're interested in the body argument from the call...
Read more >Why your mock doesn't work - Ned Batchelder
patch function in a with statement. It makes a mock object, assigns it to the name given, and then restores the original value...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
I think from a pytest perspective, this can be closed.
Is this still an issue? It is marked as “Need information”, what information is missing?