diff --git a/test/fixtures/operation_tree.py b/test/fixtures/operation_tree.py index bcc0bb27fac9fa8d1a024d67373469c52f8a45dc..7cc9e4226ea8b97c85b0171a2be99f4a90488e3b 100644 --- a/test/fixtures/operation_tree.py +++ b/test/fixtures/operation_tree.py @@ -17,6 +17,12 @@ def create_operation(_type, dest_oper, index, **kwargs): @pytest.fixture def operation_tree(): + """ + Return a addition operation connected with 2 constants. + >---C---+ + ---A + >---C---+ + """ add_oper = Addition() create_operation(Constant, add_oper, 0, value=2) create_operation(Constant, add_oper, 1, value=3) @@ -24,6 +30,16 @@ def operation_tree(): @pytest.fixture def large_operation_tree(): + """ + Return a constant operation connected with a large operation tree with 3 other constants and 3 additions. + >---C---+ + ---A---+ + >---C---+ | + +---A + >---C---+ | + ---A---+ + >---C---+ + """ add_oper = Addition() add_oper_2 = Addition() diff --git a/test/fixtures/signal.py b/test/fixtures/signal.py index 9139e93a529cc7a371426b9b97b4d31ddf95d2f7..7b13c9789f94c33338d08b48373391398bd9f71d 100644 --- a/test/fixtures/signal.py +++ b/test/fixtures/signal.py @@ -3,8 +3,10 @@ from b_asic import Signal @pytest.fixture def signal(): + """Return a signal with no connections.""" return Signal() @pytest.fixture def signals(): + """Return 3 signals with no connections.""" return [Signal() for _ in range(0,3)] diff --git a/test/graph_id/test_graph_id_generator.py b/test/graph_id/test_graph_id_generator.py index 8af36e8c1713c92a7790d30039019176ebe3bc4f..85fb088d3409432e173a8b649c7eb3e4c191d423 100644 --- a/test/graph_id/test_graph_id_generator.py +++ b/test/graph_id/test_graph_id_generator.py @@ -6,22 +6,23 @@ from b_asic.graph_id import GraphIDGenerator, GraphID import pytest -def test_empty_string_generator(): +@pytest.fixture +def graph_id_generator(): + return GraphIDGenerator() + +def test_empty_string_generator(graph_id_generator): """Test the graph id generator for an empty string type.""" - graph_id_generator = GraphIDGenerator() assert graph_id_generator.get_next_id("") == "1" assert graph_id_generator.get_next_id("") == "2" -def test_normal_string_generator(): +def test_normal_string_generator(graph_id_generator): """"Test the graph id generator for a normal string type.""" - graph_id_generator = GraphIDGenerator() assert graph_id_generator.get_next_id("add") == "add1" assert graph_id_generator.get_next_id("add") == "add2" -def test_different_strings_generator(): +def test_different_strings_generator(graph_id_generator): """Test the graph id generator for different strings.""" - graph_id_generator = GraphIDGenerator() assert graph_id_generator.get_next_id("sub") == "sub1" assert graph_id_generator.get_next_id("mul") == "mul1" assert graph_id_generator.get_next_id("sub") == "sub2"