From 79cffee230a11e2cdb9504058c68efaeb2b3c016 Mon Sep 17 00:00:00 2001 From: Thomas Roehl Date: Sat, 6 Jun 2020 03:44:46 +0200 Subject: [PATCH] Add tests for __repr__ --- tests/all_tests.py | 3 ++- tests/test_repr.py | 29 +++++++++++++++++++++++++++++ 2 files changed, 31 insertions(+), 1 deletion(-) create mode 100644 tests/test_repr.py diff --git a/tests/all_tests.py b/tests/all_tests.py index 3223c68..e536c2b 100755 --- a/tests/all_tests.py +++ b/tests/all_tests.py @@ -11,7 +11,8 @@ 'test_parsers', 'test_helpers', 'test_dmidecode_file', - 'test_machinestate' + 'test_machinestate', + 'test_repr', ] ) diff --git a/tests/test_repr.py b/tests/test_repr.py new file mode 100644 index 0000000..bd88955 --- /dev/null +++ b/tests/test_repr.py @@ -0,0 +1,29 @@ +#!/usr/bin/env python3 +""" +High-level tests for the all __repr__ functions +""" +import os +import sys +import unittest +import tempfile +import shutil +import stat +import machinestate +from locale import getpreferredencoding + +ENCODING = getpreferredencoding() + +def test_repr_sub(cls, level): + for inst in cls._instances: + print("{}{}".format(level*'\t',inst)) + if len(inst._instances) > 0: + test_repr_sub(inst, level+1) + +class TestRepr(unittest.TestCase): + def test_repr(self): + ms = machinestate.MachineState(extended=True) + ms.generate() + print("") + print(ms) + test_repr_sub(ms, 1) +