Module tests.test_builder_exception

Classes

class TestBuilderError (methodName='runTest')
Expand source code
class TestBuilderError(unittest.TestCase):
        """Tests that BuilderError.represent() works properly"""

        def test_represent(self) -> None:
                empty_child: DataNode = DataNode("Empty Child", None, [], [])
                bad_child: DataNode = DataNode("Bad Child", None, ["quid", "pro", "quo"], [empty_child])
                other_child: DataNode = DataNode("Other Child", None, ["quid", "pro", "quo"], [])
                parent: DataNode = DataNode("Parent", None, ["foo", "bar"], [bad_child, other_child])

                empty_child.parent = bad_child
                bad_child.parent = parent
                other_child.parent = parent

                self.assertEqual(
                        "Builder Exception: Message\nParent foo bar\n\t\"Bad Child\" quid pro quo",
                        BuilderError("Message", bad_child).represent()
                )

Tests that BuilderError.represent() works properly

Create an instance of the class that will use the named test method when executed. Raises a ValueError if the instance does not have a method with the specified name.

Ancestors

  • unittest.case.TestCase

Methods

def test_represent(self) ‑> None
Expand source code
def test_represent(self) -> None:
        empty_child: DataNode = DataNode("Empty Child", None, [], [])
        bad_child: DataNode = DataNode("Bad Child", None, ["quid", "pro", "quo"], [empty_child])
        other_child: DataNode = DataNode("Other Child", None, ["quid", "pro", "quo"], [])
        parent: DataNode = DataNode("Parent", None, ["foo", "bar"], [bad_child, other_child])

        empty_child.parent = bad_child
        bad_child.parent = parent
        other_child.parent = parent

        self.assertEqual(
                "Builder Exception: Message\nParent foo bar\n\t\"Bad Child\" quid pro quo",
                BuilderError("Message", bad_child).represent()
        )