moto not compatible with mock 4.0.3
See original GitHub issueVersions
Using moto-1.3.16
(boto-2.49.0 boto3-1.16.20 botocore-1.19.33)
Problem Mock has released 5h ago a new version: 4.0.3 Since then our tests are failing with the exception below.
Fix
Forcing the version of mock to 4.0.2
is solving our issue
Traceback (most recent call last):
File "/usr/local/Cellar/python@3.9/3.9.0_1/Frameworks/Python.framework/Versions/3.9/lib/python3.9/runpy.py", line 197, in _run_module_as_main
return _run_code(code, main_globals, None,
File "/usr/local/Cellar/python@3.9/3.9.0_1/Frameworks/Python.framework/Versions/3.9/lib/python3.9/runpy.py", line 87, in _run_code
exec(code, run_globals)
File "/usr/local/Cellar/python@3.9/3.9.0_1/Frameworks/Python.framework/Versions/3.9/lib/python3.9/unittest/__main__.py", line 18, in <module>
main(module=None)
File "/usr/local/Cellar/python@3.9/3.9.0_1/Frameworks/Python.framework/Versions/3.9/lib/python3.9/unittest/main.py", line 101, in __init__
self.runTests()
File "/usr/local/Cellar/python@3.9/3.9.0_1/Frameworks/Python.framework/Versions/3.9/lib/python3.9/unittest/main.py", line 271, in runTests
self.result = testRunner.run(self.test)
File "/usr/local/Cellar/python@3.9/3.9.0_1/Frameworks/Python.framework/Versions/3.9/lib/python3.9/unittest/runner.py", line 176, in run
test(result)
File "/usr/local/Cellar/python@3.9/3.9.0_1/Frameworks/Python.framework/Versions/3.9/lib/python3.9/unittest/suite.py", line 84, in __call__
return self.run(*args, **kwds)
File "/usr/local/Cellar/python@3.9/3.9.0_1/Frameworks/Python.framework/Versions/3.9/lib/python3.9/unittest/suite.py", line 122, in run
test(result)
File "/usr/local/Cellar/python@3.9/3.9.0_1/Frameworks/Python.framework/Versions/3.9/lib/python3.9/unittest/suite.py", line 84, in __call__
return self.run(*args, **kwds)
File "/usr/local/Cellar/python@3.9/3.9.0_1/Frameworks/Python.framework/Versions/3.9/lib/python3.9/unittest/suite.py", line 122, in run
test(result)
File "/usr/local/Cellar/python@3.9/3.9.0_1/Frameworks/Python.framework/Versions/3.9/lib/python3.9/unittest/suite.py", line 84, in __call__
return self.run(*args, **kwds)
File "/usr/local/Cellar/python@3.9/3.9.0_1/Frameworks/Python.framework/Versions/3.9/lib/python3.9/unittest/suite.py", line 122, in run
test(result)
File "/usr/local/Cellar/python@3.9/3.9.0_1/Frameworks/Python.framework/Versions/3.9/lib/python3.9/unittest/case.py", line 653, in __call__
return self.run(*args, **kwds)
File "../.venv/lib/python3.9/site-packages/moto/core/models.py", line 102, in wrapper
self.stop()
File "../.venv/lib/python3.9/site-packages/moto/core/models.py", line 86, in stop
self.default_session_mock.stop()
File "../.venv/lib/python3.9/site-packages/mock/mock.py", line 1563, in stop
return self.__exit__(None, None, None)
File "../.venv/lib/python3.9/site-packages/mock/mock.py", line 1529, in __exit__
if self.is_local and self.temp_original is not DEFAULT:
Issue Analytics
- State:
- Created 3 years ago
- Reactions:38
- Comments:24
Top Results From Across the Web
Getting Started with Moto — Moto 4.0.13.dev documentation
You can use pip to install the latest released version of moto , and specify which service(s) you will ... You can also...
Read more >Moto does not work with python unit test setUp() call
It appears that moto is working properly if all of the mocking code is contained in the test method.
Read more >moto - PyPI
Moto is a library that allows your tests to easily mock out AWS Services. Imagine you have the following python code that you...
Read more >Moto Documentation - Read the Docs
a package-level S3 client will properly use the mock and not reach␣ ... This is to make tests compatible with the moto server....
Read more >mock: Docs, Community, Tutorials, Reviews | Openbase
This package contains a rolling backport of the standard library mock code compatible with Python 3.6 and up. Please see the standard library...
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 have this problem as well. Using
boto3==1.16.28
my current workaround is eithermoto==1.3.14 mock==4.0.3
ormoto==1.3.16 mock==4.0.2
Thanks!
I have now
mock==4.0.3
(which wasn’t in my requirements.txt before) and I’m testing differentmoto
versions.moto==1.3.16
==> FAIL (as expected)moto==1.3.15
==> FAILmoto==1.3.14
==> PASSSo in summary this version combination worked for me: