feat: new alternate syntax and switch to black + isort (yeah, maybe not the best time, but that is done).

This commit is contained in:
Romain Dorgueil
2018-07-29 18:21:56 +01:00
parent 3094e43f9f
commit 89dda0dca6
123 changed files with 1672 additions and 1640 deletions

View File

@ -1,7 +1,7 @@
import pytest
from unittest.mock import sentinel
import pytest
from bonobo.constants import BEGIN
from bonobo.structs.graphs import Graph
@ -48,24 +48,14 @@ def test_graph_add_chain():
def test_graph_topological_sort():
g = Graph()
g.add_chain(
sentinel.a1,
sentinel.a2,
sentinel.a3,
_input=None,
_output=None,
)
g.add_chain(sentinel.a1, sentinel.a2, sentinel.a3, _input=None, _output=None)
assert g.topologically_sorted_indexes == (0, 1, 2)
assert g[0] == sentinel.a1
assert g[1] == sentinel.a2
assert g[2] == sentinel.a3
g.add_chain(
sentinel.b1,
sentinel.b2,
_output=sentinel.a2,
)
g.add_chain(sentinel.b1, sentinel.b2, _output=sentinel.a2)
assert g.topologically_sorted_indexes[-2:] == (1, 2)
assert g.topologically_sorted_indexes.index(3) < g.topologically_sorted_indexes.index(4)

View File

@ -19,7 +19,7 @@ from queue import Empty
import pytest
from bonobo.constants import BEGIN, END
from bonobo.errors import InactiveWritableError, InactiveReadableError
from bonobo.errors import InactiveReadableError, InactiveWritableError
from bonobo.structs.inputs import Input
@ -29,22 +29,22 @@ def test_input_runlevels():
# Before BEGIN, noone should be able to write in an Input queue.
assert not q.alive
with pytest.raises(InactiveWritableError):
q.put('hello, unborn queue.')
q.put("hello, unborn queue.")
# Begin
q.put(BEGIN)
assert q.alive and q._runlevel == 1
q.put('foo')
q.put("foo")
# Second Begin
q.put(BEGIN)
assert q.alive and q._runlevel == 2
q.put('bar')
q.put("bar")
q.put(END)
# FIFO
assert q.get() == 'foo'
assert q.get() == 'bar'
assert q.get() == "foo"
assert q.get() == "bar"
# self.assertEqual(q.alive, False) XXX queue don't know it's dead yet, but it is ...
# Async get raises Empty (End is not returned)
@ -53,14 +53,14 @@ def test_input_runlevels():
assert q.alive
# Before killing, let's slide some data in.
q.put('baz')
q.put("baz")
# Now kill the queue...
q.put(END)
with pytest.raises(InactiveWritableError):
q.put('foo')
q.put("foo")
# Still can get remaining data
assert q.get() == 'baz'
assert q.get() == "baz"
with pytest.raises(InactiveReadableError):
q.get()

View File

@ -2,5 +2,5 @@ from bonobo.structs.tokens import Token
def test_token_repr():
t = Token('Acme')
assert repr(t) == '<Acme>'
t = Token("Acme")
assert repr(t) == "<Acme>"