diff --git a/tests/test_debug.py b/tests/test_debug.py new file mode 100644 index 0000000..f2a2c79 --- /dev/null +++ b/tests/test_debug.py @@ -0,0 +1,35 @@ +from plasma.debug import draw, tree, info + + +class TestDebugging: + + def test_tree(self, root, grid): + lines = tree(root).split('\n') + assert lines[0].startswith('root') + assert lines[1].strip().startswith('a') + assert lines[2].strip().startswith('*') + assert lines[3].strip().startswith('b') + + def test_draw(self, root, grid): + a, *_ = grid + root._width = 24 + root._height = 10 + a.payload = 'XXXXXXXXXXXX' + data = draw(root) + assert data == ''' + ┌──────────┐┌──────────┐ + │XXXXXXXXXX││b.........│ + │..........││..........│ + │..........││..........│ + │..........│└──────────┘ + │..........│┌──┐┌──┐┌──┐ + │..........││c.││d.││e.│ + │..........││..││..││..│ + │..........││..││..││..│ + └──────────┘└──┘└──┘└──┘ + '''.replace(' ', '')[1:] + + def test_info(self, root, grid, capsys): + info(root) + out, _ = capsys.readouterr() + assert out == tree(root) + '\n' + draw(root) + '\n' diff --git a/tests/test_plasma.py b/tests/test_plasma.py index 7c23cad..0fd7197 100644 --- a/tests/test_plasma.py +++ b/tests/test_plasma.py @@ -1007,35 +1007,3 @@ def test_restore_keep_flexible(self, root, tiny_grid): assert b._size is None assert c._size == 10 -class TestDebugging: - - def test_tree(self, root, grid): - lines = tree(root).split('\n') - assert lines[0].startswith('root') - assert lines[1].strip().startswith('a') - assert lines[2].strip().startswith('*') - assert lines[3].strip().startswith('b') - - def test_draw(self, root, grid): - a, *_ = grid - root._width = 24 - root._height = 10 - a.payload = 'XXXXXXXXXXXX' - data = draw(root) - assert data == ''' - ┌──────────┐┌──────────┐ - │XXXXXXXXXX││b.........│ - │..........││..........│ - │..........││..........│ - │..........│└──────────┘ - │..........│┌──┐┌──┐┌──┐ - │..........││c.││d.││e.│ - │..........││..││..││..│ - │..........││..││..││..│ - └──────────┘└──┘└──┘└──┘ - '''.replace(' ', '')[1:] - - def test_info(self, root, grid, capsys): - info(root) - out, _ = capsys.readouterr() - assert out == tree(root) + '\n' + draw(root) + '\n'