tanuki.py
tanuki.py copied to clipboard
Tests fail when run in-bulk, but pass when run one-by-one
Something is going wrong with the state management.
When we run tests all together, several tests fail with errors such as:
self = <unittest.mock._patch object at 0x119b38650>
def get_original(self):
target = self.getter()
name = self.attribute
original = DEFAULT
local = False
try:
original = target.__dict__[name]
except (AttributeError, KeyError):
original = getattr(target, name, DEFAULT)
else:
local = True
if name in _builtins and isinstance(target, ModuleType):
self.create = True
if not self.create and original is DEFAULT:
> raise AttributeError(
"%s does not have the attribute %r" % (target, name)
)
E AttributeError: <module 'test_finance' from '/Users/.../PycharmProjects/monkeyFunctions/tests/test_patch/test_finance.py'> does not have the attribute 'classify_sentiment_2'
This is likely due to how mocked functions are scoped.