Skip to content

Commit

Permalink
Make own test file for debugging
Browse files Browse the repository at this point in the history
  • Loading branch information
numirias committed Dec 14, 2017
1 parent a856354 commit a240600
Show file tree
Hide file tree
Showing 2 changed files with 35 additions and 32 deletions.
35 changes: 35 additions & 0 deletions tests/test_debug.py
Original file line number Diff line number Diff line change
@@ -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'
32 changes: 0 additions & 32 deletions tests/test_plasma.py
Original file line number Diff line number Diff line change
Expand Up @@ -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'

0 comments on commit a240600

Please sign in to comment.