gabrielfalcao/sure

2.0.0: breaks when using Moto decorator on TestCase class

ncaunt opened this issue · 1 comments

Issue Type

Bug Report

Versions & Configuration

sure 2.0.0 (latest)
moto 2.0.10 (latest)
python 3.8.10
Apple M1 (macOS Big Sur)

Steps to reproduce (Expected and Actual Results)

When applying a Moto mock decorator to a class derived from unittest.TestCase after sure has been imported an exception is raised when the test is run with pytest. This worked as expected with sure 1.4.11.

Example exception:

_________________________________________________________________________________ ERROR collecting tests/test_sure_moto.py _________________________________________________________________________________
tests/test_sure_moto.py:20: in <module>
    class TestSureMoto(TestCase):
../../../.pyenv/versions/3.8.10/lib/python3.8/site-packages/moto/__init__.py:9: in f
    return getattr(module, element)(*args, **kwargs)
../../../.pyenv/versions/3.8.10/lib/python3.8/site-packages/moto/core/models.py:833: in __call__
    return mocked_backend(func)
../../../.pyenv/versions/3.8.10/lib/python3.8/site-packages/moto/core/models.py:66: in __call__
    return self.decorate_class(func)
../../../.pyenv/versions/3.8.10/lib/python3.8/site-packages/moto/core/models.py:135: in decorate_class
    if attr_value.__name__ not in cls.__dict__:
../../../.pyenv/versions/3.8.10/lib/python3.8/site-packages/sure/__init__.py:512: in __getattr__
    return super(AssertionBuilder, self).__getattribute__(attr)
E   AttributeError: 'AssertionBuilder' object has no attribute '__name__'

Minimal code to reproduce

from moto import mock_dynamodb2
from sure import expect
import boto3
from unittest import TestCase

@mock_dynamodb2
class TestSureMoto(TestCase):
    def test_sure_breaks(x):
        pass

As far as I'm concerned, this was an issue on Moto's side - and has been fixed with getmoto/moto#4357