def test_post_empty(capsys): """Correct empty ouput.""" a = K() a.post_order(lambda n: print(n.__str__())) sys.stderr.write("") out, err = capsys.readouterr() assert out == err
def test_breadth_empty(capsys): """Correct empty ouput.""" a = K() a.breadth_first_traversal(lambda n: print(n.__str__())) sys.stderr.write("") out, err = capsys.readouterr() assert out == err
def test_matches_many(): """All matches.""" k = K() k.insert(1) k.insert(2, 1) k.insert(2, 1) k.insert(2, 1) k = fm(k, 2) for each in k: assert each.val == 2
def test_post_no_operation(capsys): """Raise error if missing lambda.""" a = K() with pytest.raises(TypeError): assert a.post_order()
def test_breadth_no_operation(capsys): """Raise error if missing lambda.""" a = K() with pytest.raises(TypeError): assert a.breadth_first_traversal()
def test_plo_single(tree): """No children.""" k = K() k.insert(1) assert plo(k) == '1'
def test_plo_empty(): """No nodes.""" k = K() with pytest.raises(AttributeError): assert plo(k)