diff --git a/docs/source/conf.py b/docs/source/conf.py index 0036d0f8..84f0a974 100644 --- a/docs/source/conf.py +++ b/docs/source/conf.py @@ -18,11 +18,11 @@ import alabaster # noqa -import dramatiq # noqa - sys.path.insert(0, os.path.abspath('../..')) sys.path.insert(0, os.path.abspath('./')) +import dramatiq # noqa + # -- General configuration ------------------------------------------------ diff --git a/dramatiq/generic.py b/dramatiq/generic.py index b72244e5..6ad79e90 100644 --- a/dramatiq/generic.py +++ b/dramatiq/generic.py @@ -40,6 +40,9 @@ def __new__(metacls, name, bases, attrs): return clazz def __getattr__(cls, name): + if "__actor__" not in cls.__dict__: + # avoid infinite recursion on GenericActor + raise AttributeError(f"type object {cls.__name__!r} has no attribute {name!r}") return getattr(cls.__actor__, name) diff --git a/tests/test_generic_actors.py b/tests/test_generic_actors.py index c697a770..cca25fd4 100644 --- a/tests/test_generic_actors.py +++ b/tests/test_generic_actors.py @@ -117,3 +117,8 @@ def perform(self): # And the actor registry should be called with CustomActor actor_registry.assert_called_once_with(CustomActor) + + +def test_getattr_generic_actor(): + with pytest.raises(AttributeError): + dramatiq.GenericActor.missing_property