From 3d178c98e99d871c21be810e3d661af37d6a31eb Mon Sep 17 00:00:00 2001
From: Kevin Scott <kevsc634@student.liu.se>
Date: Fri, 6 Mar 2020 11:48:42 +0100
Subject: [PATCH] Added comments for fixtures

---
 test/fixtures/operation_tree.py          | 16 ++++++++++++++++
 test/fixtures/signal.py                  |  2 ++
 test/graph_id/test_graph_id_generator.py | 13 +++++++------
 3 files changed, 25 insertions(+), 6 deletions(-)

diff --git a/test/fixtures/operation_tree.py b/test/fixtures/operation_tree.py
index bcc0bb27..7cc9e422 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 9139e93a..7b13c978 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 8af36e8c..85fb088d 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"
-- 
GitLab