tanuki.py icon indicating copy to clipboard operation
tanuki.py copied to clipboard

Tests fail when run in-bulk, but pass when run one-by-one

Open JackHopkins opened this issue 1 year ago • 0 comments

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.

JackHopkins avatar Nov 27 '23 13:11 JackHopkins