ch17: update from book draft
This commit is contained in:
25
17-it-generator/tree/step1/test_tree.py
Normal file
25
17-it-generator/tree/step1/test_tree.py
Normal file
@@ -0,0 +1,25 @@
|
||||
from tree import tree
|
||||
|
||||
|
||||
def test_1_level():
|
||||
class One: pass
|
||||
expected = [('One', 0)]
|
||||
result = list(tree(One))
|
||||
assert expected == result
|
||||
|
||||
|
||||
def test_2_levels_4_leaves():
|
||||
class Branch: pass
|
||||
class Leaf1(Branch): pass
|
||||
class Leaf2(Branch): pass
|
||||
class Leaf3(Branch): pass
|
||||
class Leaf4(Branch): pass
|
||||
expected = [
|
||||
('Branch', 0),
|
||||
('Leaf1', 1),
|
||||
('Leaf2', 1),
|
||||
('Leaf3', 1),
|
||||
('Leaf4', 1),
|
||||
]
|
||||
result = list(tree(Branch))
|
||||
assert expected == result
|
||||
Reference in New Issue
Block a user