wip: version bumps & formating.

This commit is contained in:
Romain Dorgueil
2019-05-08 12:01:59 +02:00
parent ee9fbe6351
commit 72a855729c
11 changed files with 144 additions and 133 deletions

View File

@ -117,4 +117,4 @@ class CsvWriterTest(Csv, WriterTest, TestCase):
context.write_sync(EMPTY, EMPTY, EMPTY)
context.stop()
assert self.readlines() == ('', '', '')
assert self.readlines() == ("", "", "")

View File

@ -119,23 +119,26 @@ def test_methodcaller():
MyBag = BagType("MyBag", ["a", "b", "c"])
@pytest.mark.parametrize("input_, key, expected", [
(MyBag(1, 2, 3), True, MyBag(1, 4, 9)),
(MyBag(1, 2, 3), False, MyBag(1, 2, 3)),
(MyBag(1, 2, 3), lambda x: x == 'c', MyBag(1, 2, 9)),
((1, 2, 3), True, (1, 4, 9)),
((1, 2, 3), False, (1, 2, 3)),
])
@pytest.mark.parametrize(
"input_, key, expected",
[
(MyBag(1, 2, 3), True, MyBag(1, 4, 9)),
(MyBag(1, 2, 3), False, MyBag(1, 2, 3)),
(MyBag(1, 2, 3), lambda x: x == "c", MyBag(1, 2, 9)),
((1, 2, 3), True, (1, 4, 9)),
((1, 2, 3), False, (1, 2, 3)),
],
)
def test_map_fields(input_, key, expected):
with BufferingNodeExecutionContext(bonobo.MapFields(lambda x: x**2, key)) as context:
with BufferingNodeExecutionContext(bonobo.MapFields(lambda x: x ** 2, key)) as context:
context.write_sync(input_)
assert context.status == '-'
assert context.status == "-"
[got] = context.get_buffer()
assert expected == got
def test_map_fields_error():
with BufferingNodeExecutionContext(bonobo.MapFields(lambda x: x**2, lambda x: x == 'c')) as context:
with BufferingNodeExecutionContext(bonobo.MapFields(lambda x: x ** 2, lambda x: x == "c")) as context:
context.write_sync(tuple())
assert context.status == '!'
assert context.status == "!"
assert context.defunct

View File

@ -1,7 +1,7 @@
import pytest
from bonobo.util import ensure_tuple, sortedlist
from bonobo.util.collections import cast, tuplize, tuple_or_const
from bonobo.util.collections import cast, tuple_or_const, tuplize
def test_sortedlist():
@ -15,10 +15,11 @@ def test_sortedlist():
def test_tuple_or_const():
assert tuple_or_const(()) == ()
assert tuple_or_const((1, )) == (1, )
assert tuple_or_const((1, 2, )) == (1, 2, )
assert tuple_or_const([1, 2, ]) == (1, 2, )
assert tuple_or_const("aaa") == ('aaa', )
assert tuple_or_const((1,)) == (1,)
assert tuple_or_const((1, 2)) == (1, 2)
assert tuple_or_const([1, 2]) == (1, 2)
assert tuple_or_const("aaa") == ("aaa",)
def test_ensure_tuple():
assert ensure_tuple("a") == ("a",)