Skip to content

Commit

Permalink
Declare interface methods as staticmethod
Browse files Browse the repository at this point in the history
  • Loading branch information
daltonmatos committed Aug 10, 2013
1 parent b7eb0fe commit bf35d1d
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 2 deletions.
2 changes: 1 addition & 1 deletion plugnplay/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@


def _is_method(o):
return type(o) is FunctionType
return type(o) in (FunctionType, staticmethod)


def method_name(method_name):
Expand Down
11 changes: 10 additions & 1 deletion tests/calling.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,11 @@

class SomeIface(plugnplay.Interface):

def one_method(self, p1, p2):
@staticmethod
def one_method(p1, p2):
pass

def other_method(self, a, b):
pass


Expand All @@ -14,6 +18,11 @@ class CallTest(unittest.TestCase):
def test_call_implementors(self):
plugin_mock = Mock()
plugnplay.man.add_implementor(SomeIface, plugin_mock)

SomeIface.one_method(1, 2)
self.assertEquals(1, plugin_mock.one_method.call_count)
plugin_mock.one_method.assert_called_with(1, 2)

SomeIface.other_method(3, 4)
self.assertEquals(1, plugin_mock.other_method.call_count)
plugin_mock.other_method.assert_called_with(3, 4)

0 comments on commit bf35d1d

Please sign in to comment.