def test_division_given_addition_to_string(): """.""" tree = Div(Add(Leaf(12), Leaf(6)), Leaf(6)) assert tree.apply() == 3 assert tree.__str__() == "(12 + 6) / 6"
def test_addition_with_leaves_to_class_string(): """.""" assert eval(Add(Leaf(5), Leaf(6)).class_str()).apply() == 11
def test_addition_with_leaves_to_string(): """.""" tree = Add(Leaf(5), Leaf(6)) assert tree.apply() == 11 assert tree.__str__() == "5 + 6"
def test_addition_adds_when_given_leaves_with_numbers(): """.""" assert Add(Leaf(5), Leaf(6)).apply() == 11
def test_addition_adds_when_given_leaves_with_numbers_deeper(): """.""" assert Add(Add(Add(Add(Leaf(6), Leaf(6)), Leaf(6)), Leaf(6)), Leaf(6)).apply() == 30
def test_addition_doesnt_equal_addition_when_different_value(): """.""" assert Add(Leaf(2), Leaf(1)) != Add(Leaf(1), Leaf(2))
def test_set_add_adds_when_given_leaves_with_sets(): """.""" assert Add(Leaf({5}), Leaf({6})).apply() == {5, 6}
def test_division_given_addition_to_string(): """.""" tree = Add(Sub(Leaf(5), Leaf(6)), Sub(Leaf(5), Leaf(6))) """assert tree.apply() == 3""" assert tree.__str__() == "(5 - 6) + (5 - 6)"
def test_addition_equals_addition_when_same_value(): """.""" assert Add(Leaf(1), Leaf(2)) == Add(Leaf(1), Leaf(2))
def test_division_given_addition_to_string(): """.""" tree = Add(Leaf(3), Div(Add(Leaf(12), Leaf(6)), Leaf(6))) """assert tree.apply() == 3""" assert tree.__str__() == '3 + (12 + 6) / 6'
def test_multiplication_given_addition_given_addition_to_string(): """. Tree node class str.""" tree = Add(Leaf(3), Div(Add(Leaf(12), Leaf(6)), Leaf(6))) assert tree.__str__() == "3 + (12 + 6) / 6"
def test_addition_given_addition_to_class_string(): """. Tree node class str.""" assert eval(Add(Add(Leaf(5), Leaf(6)), Add(Leaf(5), Leaf(6))).class_str()).apply() == 22
def test_leaf_to_class_string1(): """.""" assert Add(Leaf(5), Leaf(6)).class_str() == "Add(Leaf(5), Leaf(6))"
def test_no_apply(): """.""" assert Add(Add(Leaf(5), Leaf(6)), Add(Leaf(5), Leaf(6))).class_str() \ == "Add(Add(Leaf(5), Leaf(6)), Add(Leaf(5), Leaf(6)))"