Esempio n. 1
0
def test_Buzz_check_expressions__basic():
    with pytest.raises(Buzz) as err_info:
        with Buzz.check_expressions("there will be errors") as check:
            check(True)
            check(False)
            check(1 == 2, "one is not two")
            check("cooooooool", "not a problem")
            check(0, "zero is still zero")
    err_msg = err_info.value.message
    assert "there will be errors" in err_msg
    assert "1st expression failed" not in err_msg
    assert "2nd expression failed" in err_msg
    assert "one is not two" in err_msg
    assert "not a problem" not in err_msg
    assert "zero is still zero" in err_msg
Esempio n. 2
0
 def test_check_expressions(self):
     with pytest.raises(Buzz) as err_info:
         with Buzz.check_expressions(
                 main_message='there will be errors', ) as check:
             check(True)
             check(False)
             check(1 == 2, "one is not two")
             check('cooooooool', 'not a problem')
             check(0, "zero is still zero")
     err_msg = err_info.value.message
     assert 'there will be errors' in err_msg
     assert '1st expression failed' not in err_msg
     assert '2nd expression failed' in err_msg
     assert 'one is not two' in err_msg
     assert 'not a problem' not in err_msg
     assert 'zero is still zero' in err_msg
Esempio n. 3
0
def test_Buzz_check_exressions__fails_with_explicitly_passed_raise_exc_class():
    with pytest.raises(ValueError, match="You may not pass"):
        with Buzz.check_expressions("there will be errors",
                                    raise_exc_class=Exception) as check:
            check(True)