I am migrating python's version (2->3) of my project. The tests works fine for python2, but complains for python3, the error is like
TypeError: '>' not supported between instances of 'MagicMock' and 'int'
here is a minimal case
# test_mock.py
try:
from mock import MagicMock
except:
from unittest.mock import MagicMock
def test_mock_func():
a = MagicMock()
b = a.value
if b > 100:
assert True
else:
assert True
just run py.test .
These hacks not work
MagicMock.__le__ = some_le_method # just not working
MagicMock.__le__.__func__.__code = some_le_method.__func__.__code__ # wrapper_descriptor does not have attribute __func__