Updating moto from version 1.3.14 to 1.3.15/1.3.16 breaks tests throwing an Exception.
It throws an error even using the annotation alone.
I using this requiriments.txt
file:
moto==1.3.16
This test example is working with moto 1.3.14 but it is not with newer versions:
from moto import mock_s3
import unittest
@mock_s3
class TestStringMethods(unittest.TestCase):
def test_upper(self):
self.assertEqual('foo'.upper(), 'FOO')
if __name__ == '__main__':
unittest.main()
This is the error when executing python3 -m unittest mytest.py
:
(venv) ~/p/mocotest $ python3 -m unittest mytest.py
ETraceback (most recent call last):
File "/usr/lib/python3.8/runpy.py", line 194, in _run_module_as_main
return _run_code(code, main_globals, None,
File "/usr/lib/python3.8/runpy.py", line 87, in _run_code
exec(code, run_globals)
File "/usr/lib/python3.8/unittest/__main__.py", line 18, in <module>
main(module=None)
File "/usr/lib/python3.8/unittest/main.py", line 101, in __init__
self.runTests()
File "/usr/lib/python3.8/unittest/main.py", line 271, in runTests
self.result = testRunner.run(self.test)
File "/usr/lib/python3.8/unittest/runner.py", line 176, in run
test(result)
File "/usr/lib/python3.8/unittest/suite.py", line 84, in __call__
return self.run(*args, **kwds)
File "/usr/lib/python3.8/unittest/suite.py", line 122, in run
test(result)
File "/usr/lib/python3.8/unittest/suite.py", line 84, in __call__
return self.run(*args, **kwds)
File "/usr/lib/python3.8/unittest/suite.py", line 122, in run
test(result)
File "/usr/lib/python3.8/unittest/suite.py", line 84, in __call__
return self.run(*args, **kwds)
File "/usr/lib/python3.8/unittest/suite.py", line 122, in run
test(result)
File "/usr/lib/python3.8/unittest/case.py", line 736, in __call__
return self.run(*args, **kwds)
File "/home/cerveraa/projects/mocotest/venv/lib/python3.8/site-packages/moto/core/models.py", line 102, in wrapper
self.stop()
File "/home/cerveraa/projects/mocotest/venv/lib/python3.8/site-packages/moto/core/models.py", line 86, in stop
self.default_session_mock.stop()
File "/home/cerveraa/projects/mocotest/venv/lib/python3.8/site-packages/mock/mock.py", line 1563, in stop
return self.__exit__(None, None, None)
File "/home/cerveraa/projects/mocotest/venv/lib/python3.8/site-packages/mock/mock.py", line 1529, in __exit__
if self.is_local and self.temp_original is not DEFAULT:
AttributeError: '_patch' object has no attribute 'is_local'
Versions:
- Python 3.8.5
- pip 20.0.2
Any suggestion?
Note 1:
For testing, I'm using a clean new venv
environment and the only library installed is moto
.
Note 2: Using 1.3.14 works fine, but with a warning when installing dependencies:
ERROR: python-jose 3.2.0 has requirement ecdsa<0.15, but you'll have ecdsa 0.16.1 which is incompatible
moto
andmock
librariesmoto==1.3.16
and mock versionmock==4.0.2
solved the issue for me.