Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion dramatiq/generic.py
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ def __name__(self):
def __call__(self, *args, **kwargs):
return self.perform(*args, **kwargs)

def perform(self):
def perform(self, *args, **kwargs):
"""This is the method that gets called when the actor receives
a message. All non-abstract subclasses must implement this
method.
Expand Down
24 changes: 24 additions & 0 deletions tests/test_generic_actors.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,30 @@ class Foo(dramatiq.GenericActor):
Foo()


def test_generic_actors_raise_not_implemented_if_perform_is_missing_and_called_with_args(stub_broker):
# Reggression test for #805
# Given that I've subclassed GenericActor without implementing perform
class Foo(dramatiq.GenericActor):
pass

# When I call that actor with some arguments
# Then a NotImplementedError should be raised
with pytest.raises(NotImplementedError, match=r"Foo does not implement perform\(\)"):
Foo(1, foo="bar")


def test_generic_actors_raise_type_error_if_perform_is_called_with_wrong_args(stub_broker):
# Given that I've subclassed GenericActor without implementing perform
class Foo(dramatiq.GenericActor):
def perform(self, foo):
pass

# When I call that actor with the wrong arguments
# Then a TypeError should be raised
with pytest.raises(TypeError, match=r"\.Foo\.perform\(\) got an unexpected keyword argument 'bar'"):
Foo(bar=2)


def test_generic_actors_can_be_abstract(stub_broker, stub_worker):
# Given that I have a calls database
calls = set()
Expand Down