We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
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
Hello, sorry for opening issue, didn't find a better place to ask.
I'm wondering how I can replace this code:
with patch("service.services.MyService") as mock: mock.return_value.attribute = {'key': 'value'}
using mocker, I've tried this code, but it didn't work:
mocker.patch( "service.services.MyService.attribute", return_value={'key': 'value'}, create=True # otherwise it fails with AttributeError )
The text was updated successfully, but these errors were encountered:
Hi @xmalter,
It is similar, mocker.patch also return a MagicMock:
mocker.patch
MagicMock
mock = mocker.patch("service.services.MyService.attribute") mock.return_value.attribute = {'key': 'value'}
Sorry, something went wrong.
Thanks!
Actually it's
mock = mocker.patch("service.services.MyService") # <- No attribute here mock.return_value.attribute = {'key': 'value'}
Otherwise it fails with AttributeError
AttributeError
No branches or pull requests
Hello, sorry for opening issue, didn't find a better place to ask.
I'm wondering how I can replace this code:
using mocker, I've tried this code, but it didn't work:
The text was updated successfully, but these errors were encountered: