def test_failure(self): c = Checker() try: with c.expect("This should work"): c.fail("It failed!") self.fail("We shouldn't have run past a c.fail") # pragma: nocover self.fail("We shouldn't have continued after a failed c.should") # pragma: nocover except Checker.Done: pass self.assertEqual(c.results, [{"status": "FAIL", "expect": "This should work", "did": "It failed!"}])
def test_failure_with_continue_on_fail(self): c = Checker() try: with c.expect("This should work", continue_on_fail=True): c.fail("It failed!") self.fail("We shouldn't have run past a c.fail") # pragma: nocover with c.expect("Also this one"): pass except Checker.Done: # pragma: nocover self.fail("Shouldn't have raised Done here.") self.assertEqual( c.results, [ {"status": "FAIL", "expect": "This should work", "did": "It failed!"}, {"status": "OK", "expect": "Also this one"}, ], )
def test_failure(self): c = Checker() try: with c.expect("This should work"): c.fail("It failed!") self.fail( "We shouldn't have run past a c.fail") # pragma: nocover self.fail("We shouldn't have continued after a failed c.should" ) # pragma: nocover except Checker.Done: pass self.assertEqual(c.results, [ { 'status': 'FAIL', 'expect': "This should work", 'did': "It failed!" }, ])
def test_failure_with_continue_on_fail(self): c = Checker() try: with c.expect("This should work", continue_on_fail=True): c.fail("It failed!") self.fail( "We shouldn't have run past a c.fail") # pragma: nocover with c.expect("Also this one"): pass except Checker.Done: # pragma: nocover self.fail("Shouldn't have raised Done here.") self.assertEqual(c.results, [ { 'status': 'FAIL', 'expect': "This should work", 'did': "It failed!" }, { 'status': 'OK', 'expect': "Also this one" }, ])