Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

__getattr__ should raise AttributeError, not EventsException #17

Open
DavidCurtiss opened this issue Mar 27, 2020 · 0 comments
Open

__getattr__ should raise AttributeError, not EventsException #17

DavidCurtiss opened this issue Mar 27, 2020 · 0 comments

Comments

@DavidCurtiss
Copy link

When __getattr__ raises an EventsException for a missing attribute, it breaks getattr(obj, name, default).

Simple test that reproduces it:

class TestGetattr(TestBase):

    def test_getattr(self):
        events = Events(('on_event', ))
        assert getattr(events, "blah", None) is None

This is a problem for me because in python 3.8, creating a Mock of an object that has events runs into this issue. Here's the corresponding test case for python 3.8:

class TestMocking(TestBase):

    def test_mock(self):
        class MyEvents(Events):
            __events__ = ('on_eventOne', )
            _instance = None

        MyEvents._instance = MyEvents()

        # In python 3.8, this results in "EventsException: Event '_is_coroutine' is not declared"
        unittest.mock.Mock(MyEvents)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant