feat: new alternate syntax and switch to black + isort (yeah, maybe not the best time, but that is done).
This commit is contained in:
@ -1,7 +1,7 @@
|
||||
from operator import attrgetter
|
||||
|
||||
from bonobo.config import Configurable
|
||||
from bonobo.config.processors import ContextProcessor, resolve_processors, ContextCurrifier, use_context_processor
|
||||
from bonobo.config.processors import ContextCurrifier, ContextProcessor, resolve_processors, use_context_processor
|
||||
|
||||
|
||||
class CP1(Configurable):
|
||||
@ -11,11 +11,11 @@ class CP1(Configurable):
|
||||
|
||||
@ContextProcessor
|
||||
def a(self):
|
||||
yield 'this is A'
|
||||
yield "this is A"
|
||||
|
||||
@ContextProcessor
|
||||
def b(self, a):
|
||||
yield a.upper()[:-1] + 'b'
|
||||
yield a.upper()[:-1] + "b"
|
||||
|
||||
def __call__(self, a, b):
|
||||
return a, b
|
||||
@ -46,20 +46,20 @@ class CP3(CP2):
|
||||
|
||||
|
||||
def get_all_processors_names(cls):
|
||||
return list(map(attrgetter('__name__'), resolve_processors(cls)))
|
||||
return list(map(attrgetter("__name__"), resolve_processors(cls)))
|
||||
|
||||
|
||||
def test_inheritance_and_ordering():
|
||||
assert get_all_processors_names(CP1) == ['c', 'a', 'b']
|
||||
assert get_all_processors_names(CP2) == ['c', 'a', 'b', 'f', 'e', 'd']
|
||||
assert get_all_processors_names(CP3) == ['c', 'a', 'b', 'f', 'e', 'd', 'c', 'b']
|
||||
assert get_all_processors_names(CP1) == ["c", "a", "b"]
|
||||
assert get_all_processors_names(CP2) == ["c", "a", "b", "f", "e", "d"]
|
||||
assert get_all_processors_names(CP3) == ["c", "a", "b", "f", "e", "d", "c", "b"]
|
||||
|
||||
|
||||
def test_setup_teardown():
|
||||
o = CP1()
|
||||
stack = ContextCurrifier(o)
|
||||
stack.setup()
|
||||
assert o(*stack.args) == ('this is A', 'THIS IS b')
|
||||
assert o(*stack.args) == ("this is A", "THIS IS b")
|
||||
stack.teardown()
|
||||
|
||||
|
||||
@ -71,4 +71,4 @@ def test_processors_on_func():
|
||||
def node(context):
|
||||
pass
|
||||
|
||||
assert get_all_processors_names(node) == ['cp']
|
||||
assert get_all_processors_names(node) == ["cp"]
|
||||
|
||||
Reference in New Issue
Block a user