Comments (3)
Hi,
We use mock.patch.object
, which seems to install this happily in attributes too:
pytest-mock/src/pytest_mock/plugin.py
Line 178 in 1ff80b2
from pytest-mock.
Hi,
Thanks for the quick reply. Sure, mock.patch.object
has no problem creating that object but it also has no problem with something like
patch.object(my_class, "not_attribute")
while spy will throw an Error. Just thought the behavior was kind of weird. By the way, the reason it throws an error is because of the first line of the spy method:
method = getattr(obj, name)
Thought maybe you could treat attributes / properties somewhat differently and at the same time solve this issue for example: #35
Let me know what you think, cheers.
from pytest-mock.
To be honest I'm not sure how to proceed, particularly I don't have a solution or strong opinion on this.
I suggest we move this discussion over #35, as these two topics are basically the same. 👍
Closing this issue, feel free to follow up on #35 if you have a proposal to move this forward.
from pytest-mock.
Related Issues (20)
- 6 tests fail HOT 1
- mocker.patch does not change return value HOT 3
- missing 1 required positional argument: 'mocker' HOT 3
- assert_called_once_with calls __eq__ multiple times HOT 3
- sdist is missing tox.ini HOT 1
- 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
- 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
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.