Comments (3)
Hi,
Did not take a deep look at the code, but probably is the matter of patching in the wrong place, see Where to patch.
from pytest-mock.
I tried to patch on every single lines without better result :/
PS: maybe related to something with async?
from pytest-mock.
If you print the get_user_id
at the place where it is used (IOW, where you expect the patch to have changed it) you will notice that it points to the original function, not to a MagicMock
object. This might give a clue where you should be patching.
Another thing you can try is to write assert 0
in the line you call mocker.patch
and another assert 0
in the line where get_user_id
is used: if the latter is hit first, then it means you are patching it too late.
PS: maybe related to something with async?
Don't think so, shouldn't really affect mocking.
from pytest-mock.
Related Issues (20)
- Spying on pydantic objects HOT 1
- Changelog broken HOT 2
- Mock method don't work when test from other file fail HOT 4
- async_stub doesn't need to be awaited HOT 1
- mocker.stub() is a coroutine function HOT 1
- feature request: fail on improper use of mock.side_effect HOT 2
- Record multiple calls to spy HOT 2
- How to patch return_value attribute? HOT 2
- The documentation should be clearer about not supporting context managers HOT 1
- Not sure why this is not working HOT 3
- `resetall` does not work when using `create_autospec` HOT 2
- Behavior of spy on class attributes HOT 3
- Call args/kwargs stored in a Spy can be overwritten without intention HOT 1
- test_failure_message_with_no_name fails with 3.11.7/3.12.1 HOT 1
- Failing tests for python 3.12 HOT 1
- Allow for easier import of `mocker.Mock | mocker.MagicMock` types
- [3.13.0] New logged calls in MagicMock mock_calls attribute HOT 7
- Test failure in test_repr_with_name with Python 3.12.0 HOT 1
- Mocked socket interfering with pytest-asyncio's teardown HOT 1
- mocker.patch.object behaves differently than it's unittest.mock counterpart HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from pytest-mock.