def test_check_state_false_no_msg(self): with self.assertRaises(IllegalStateException) as context: Preconditions.check_state(False) self.assertTrue(isinstance(context.exception, IllegalStateException))
def test_check_state_false_msg(self): m = "message" with self.assertRaises(IllegalStateException) as context: Preconditions.check_state(False, m) self.assertTrue(m in str(context.exception))
def test_check_state_true_msg(self): try: Preconditions.check_state(True, "message") except IllegalStateException: # pragma: no cover self.fail("check_state() raised IllegalStateException " "unexpectedly!") # pragma: no cover