Removes unused functions and test bag application to iterables.
This commit is contained in:
@ -1,11 +1,11 @@
|
||||
from unittest.mock import Mock
|
||||
import pickle
|
||||
from unittest.mock import Mock
|
||||
|
||||
from bonobo import Bag
|
||||
from bonobo.constants import INHERIT_INPUT
|
||||
from bonobo.structs import Token
|
||||
|
||||
args = ('foo', 'bar', )
|
||||
args = ('foo', 'bar',)
|
||||
kwargs = dict(acme='corp')
|
||||
|
||||
|
||||
@ -34,29 +34,29 @@ def test_inherit():
|
||||
bag3 = bag.extend('c', c=3)
|
||||
bag4 = Bag('d', d=4)
|
||||
|
||||
assert bag.args == ('a', )
|
||||
assert bag.args == ('a',)
|
||||
assert bag.kwargs == {'a': 1}
|
||||
assert bag.flags is ()
|
||||
|
||||
assert bag2.args == ('a', 'b', )
|
||||
assert bag2.args == ('a', 'b',)
|
||||
assert bag2.kwargs == {'a': 1, 'b': 2}
|
||||
assert INHERIT_INPUT in bag2.flags
|
||||
|
||||
assert bag3.args == ('a', 'c', )
|
||||
assert bag3.args == ('a', 'c',)
|
||||
assert bag3.kwargs == {'a': 1, 'c': 3}
|
||||
assert bag3.flags is ()
|
||||
|
||||
assert bag4.args == ('d', )
|
||||
assert bag4.args == ('d',)
|
||||
assert bag4.kwargs == {'d': 4}
|
||||
assert bag4.flags is ()
|
||||
|
||||
bag4.set_parent(bag)
|
||||
assert bag4.args == ('a', 'd', )
|
||||
assert bag4.args == ('a', 'd',)
|
||||
assert bag4.kwargs == {'a': 1, 'd': 4}
|
||||
assert bag4.flags is ()
|
||||
|
||||
bag4.set_parent(bag3)
|
||||
assert bag4.args == ('a', 'c', 'd', )
|
||||
assert bag4.args == ('a', 'c', 'd',)
|
||||
assert bag4.kwargs == {'a': 1, 'c': 3, 'd': 4}
|
||||
assert bag4.flags is ()
|
||||
|
||||
@ -87,3 +87,11 @@ def test_eq_operator():
|
||||
def test_repr():
|
||||
bag = Bag('a', a=1)
|
||||
assert repr(bag) == "<Bag ('a', a=1)>"
|
||||
|
||||
|
||||
def test_iterator():
|
||||
bag = Bag()
|
||||
assert list(bag.apply([1, 2, 3])) == [1, 2, 3]
|
||||
assert list(bag.apply((1, 2, 3))) == [1, 2, 3]
|
||||
assert list(bag.apply(range(5))) == [0, 1, 2, 3, 4]
|
||||
assert list(bag.apply('azerty')) == ['a', 'z', 'e', 'r', 't', 'y']
|
||||
|
||||
24
tests/util/test_compat.py
Normal file
24
tests/util/test_compat.py
Normal file
@ -0,0 +1,24 @@
|
||||
import pytest
|
||||
|
||||
from bonobo.util.compat import deprecated, deprecated_alias
|
||||
|
||||
|
||||
def test_deprecated():
|
||||
@deprecated
|
||||
def foo():
|
||||
pass
|
||||
|
||||
foo = deprecated(foo)
|
||||
with pytest.warns(DeprecationWarning):
|
||||
foo()
|
||||
|
||||
|
||||
def test_deprecated_alias():
|
||||
def foo():
|
||||
pass
|
||||
|
||||
foo = deprecated_alias('bar', foo)
|
||||
|
||||
with pytest.warns(DeprecationWarning):
|
||||
foo()
|
||||
|
||||
Reference in New Issue
Block a user