def test_divide_divides_when_given_leaves_with_numbers(): """.""" assert Div(Div(Div(Div(Leaf(6), Leaf(6)), Leaf(6)), Leaf(6)), Leaf(6)).apply() == 0
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_bitwise_or_given_bitwise_and_given_div_given_mul_given_bitwise_pow_to_string( ): """.""" tree = Or(And(Leaf(3), Div()), ) assert tree.__str__() == "3 & 1 | 5 ** 2 * 1 / 5 & 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_set_division_subtracts_when_given_subtraction_with_int(): """.""" assert Div(Sub(Leaf({5}), Leaf({7})), Div(Leaf(5), Leaf(6))).apply() == {5}
def test_set_div_divides_when_given_leaves_with_sets(): """.""" assert Div(Leaf({5, 6}), Leaf({6})).apply() == {5}
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"