moto: moto not compatible with mock 4.0.3
Versions
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:
About this issue
- Original URL
- State: closed
- Created 4 years ago
- Reactions: 38
- Comments: 24
Commits related to this issue
- #3535 - Unpatch only once during teardown — committed to bblommers/moto by bblommers 4 years ago
- create docker-compose dev setup In order to simplify the setup for local development, the necessary utils Postgres and MinIO are wrapped in a docker-compose file. The existing docker-compose.yml use... — committed to geoadmin/service-stac by boecklic 4 years ago
- create docker-compose dev setup In order to simplify the setup for local development, the necessary utils Postgres and MinIO are wrapped in a docker-compose file. The existing docker-compose.yml use... — committed to geoadmin/service-stac by boecklic 4 years ago
- Change the ccommand to install the package moto(required for testing) to include the specific version 1.3.14. The latest version of moto is not compatible with the latest version of mock. https://gith... — committed to aws-solutions/document-understanding-solution by ShivaniMehendarge 4 years ago
- Fix Mock 4.0.3 compatibility - Unpatch only once during teardown (#3541) * #3535 - Unpatch only once during teardown * EnvVar patching - Fix Python2 bug * Allow latest version of mock-library — committed to getmoto/moto by bblommers 3 years ago
- update from master (#1) * Fix Mock 4.0.3 compatibility - Unpatch only once during teardown (#3541) * #3535 - Unpatch only once during teardown * EnvVar patching - Fix Python2 bug * Allow lat... — committed to tony-dot-sh/moto by tony-dot-sh 3 years ago
- Upgrades moto to newer version (~=2.0) According to https://github.com/spulec/moto/issues/3535#issuecomment-808706939 1.3.17 version of moto with a fix to be compatible with mock> 4.0.3 is not going ... — committed to potiuk/airflow by potiuk 3 years ago
- Upgrades moto to newer version (~=2.0) (#15051) According to https://github.com/spulec/moto/issues/3535#issuecomment-808706939 1.3.17 version of moto with a fix to be compatible with mock> 4.0.3 is ... — committed to apache/airflow by potiuk 3 years ago
- Adds dill exclusion to Dockerfiles to accomodate upcoming beam fix (#15048) * Upgrades moto to newer version (~=2.0) According to https://github.com/spulec/moto/issues/3535#issuecomment-808706939 ... — committed to apache/airflow by potiuk 3 years ago
- Upgrades moto to newer version (~=2.0) (#15051) According to https://github.com/spulec/moto/issues/3535#issuecomment-808706939 1.3.17 version of moto with a fix to be compatible with mock> 4.0.3 is n... — committed to apache/airflow by potiuk 3 years ago
- Adds dill exclusion to Dockerfiles to accomodate upcoming beam fix (#15048) * Upgrades moto to newer version (~=2.0) According to https://github.com/spulec/moto/issues/3535#issuecomment-808706939 1.... — committed to apache/airflow by potiuk 3 years ago
- Upgrades moto to newer version (~=2.0) (#15051) According to https://github.com/spulec/moto/issues/3535#issuecomment-808706939 1.3.17 version of moto with a fix to be compatible with mock> 4.0.3 is n... — committed to apache/airflow by potiuk 3 years ago
- Adds dill exclusion to Dockerfiles to accomodate upcoming beam fix (#15048) * Upgrades moto to newer version (~=2.0) According to https://github.com/spulec/moto/issues/3535#issuecomment-808706939 1.... — committed to apache/airflow by potiuk 3 years ago
- Upgrades moto to newer version (~=2.0) (#15051) According to https://github.com/spulec/moto/issues/3535#issuecomment-808706939 1.3.17 version of moto with a fix to be compatible with mock> 4.0.3 is n... — committed to GoogleCloudPlatform/composer-airflow by potiuk 3 years ago
- Adds dill exclusion to Dockerfiles to accomodate upcoming beam fix (#15048) * Upgrades moto to newer version (~=2.0) According to https://github.com/spulec/moto/issues/3535#issuecomment-808706939 1.... — committed to GoogleCloudPlatform/composer-airflow by potiuk 3 years ago
I have this problem as well. Using
boto3==1.16.28my current workaround is eithermoto==1.3.14 mock==4.0.3ormoto==1.3.16 mock==4.0.2Thanks!
I have now
mock==4.0.3(which wasn’t in my requirements.txt before) and I’m testing differentmotoversions.moto==1.3.16==> FAIL (as expected)moto==1.3.15==> FAILmoto==1.3.14==> PASSSo in summary this version combination worked for me:
To add search visibility, in my case the tests were failing with
While we wait on the PR, I just threw in the
mock==4.0.2requirement.We’ve just released a fix, and Moto >= 1.3.17.dev264 should be compatible with mock == 4.0.3.
Please let us know if you’re still experiencing issues.
can you try this?
That boundary should be fine afaik, @potiuk. Moto only requires boto3>=1.9.201, because they do a good job of keeping things backward compatible. There’s no relation between versions, though. There are best efforts to keep it working with the latest version of boto3, and to only require a boto3-update if absolutely necessary.
For reference. I was receiving the following TypeError:
When executing the following code:
It was fixed as suggested by @marcelloromani by setting
Thanks @ostashkevych - didn’t think about the possibility of a class-decorator. i can reproduce it with that.
Attached a PR that should fix this issue.