コード例 #1
0
ファイル: test_run.py プロジェクト: nedbat/choosy
 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!"}])
コード例 #2
0
ファイル: test_run.py プロジェクト: nedbat/choosy
 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"},
         ],
     )
コード例 #3
0
ファイル: test_run.py プロジェクト: sembug/choosy
 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!"
         },
     ])
コード例 #4
0
ファイル: test_run.py プロジェクト: sembug/choosy
 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"
         },
     ])