Fix Method to be non positional as there is a randomly happening bug that I cannot trace.

This commit is contained in:
Romain Dorgueil
2017-05-22 10:35:24 +02:00
parent 88df694dc1
commit a45a6830c7
3 changed files with 22 additions and 10 deletions

View File

@ -15,7 +15,6 @@ class MethodBasedConfigurable(Configurable):
def test_one_wrapper_only():
with pytest.raises(ConfigurationError):
class TwoMethods(Configurable):
h1 = Method()
h2 = Method()
@ -28,7 +27,12 @@ def test_define_with_decorator():
def Concrete(self, *args, **kwargs):
calls.append((args, kwargs, ))
print('handler', Concrete.handler)
assert callable(Concrete.handler)
t = Concrete('foo', bar='baz')
assert callable(t.handler)
assert len(calls) == 0
t()
assert len(calls) == 1
@ -41,6 +45,7 @@ def test_define_with_argument():
calls.append((args, kwargs, ))
t = MethodBasedConfigurable('foo', bar='baz', handler=concrete_handler)
assert callable(t.handler)
assert len(calls) == 0
t()
assert len(calls) == 1
@ -54,6 +59,7 @@ def test_define_with_inheritance():
calls.append((args, kwargs, ))
t = Inheriting('foo', bar='baz')
assert callable(t.handler)
assert len(calls) == 0
t()
assert len(calls) == 1
@ -69,7 +75,9 @@ def test_inheritance_then_decorate():
def Concrete(self, *args, **kwargs):
calls.append((args, kwargs, ))
assert callable(Concrete.handler)
t = Concrete('foo', bar='baz')
assert callable(t.handler)
assert len(calls) == 0
t()
assert len(calls) == 1