Skip to content

Commit

Permalink
Add tests for __repr__
Browse files Browse the repository at this point in the history
  • Loading branch information
TomTheBear committed Jun 6, 2020
1 parent 6ae7137 commit 79cffee
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 1 deletion.
3 changes: 2 additions & 1 deletion tests/all_tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,8 @@
'test_parsers',
'test_helpers',
'test_dmidecode_file',
'test_machinestate'
'test_machinestate',
'test_repr',
]
)

Expand Down
29 changes: 29 additions & 0 deletions tests/test_repr.py
Original file line number Diff line number Diff line change
@@ -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)

0 comments on commit 79cffee

Please sign in to comment.