Exemplo n.º 1
0
         (State.DO_NOT_SHARE, 300.0, 100.0, True),
         (State.DO_NOT_SHARE, 300.0, 290.0, False),
         (State.FAIL, 300.0, 290.0, False),
         (State.FAIL, 300.0, 100.0, True),
         (State.TIMEOUT, 300.0, 290.0, False),
         (State.TIMEOUT, 300.0, 100.0, True),
     ],
 )
 async def test_on_suite_fail(
     self, initial_state, now, failed, posts_report, *, case
 ):
     case.log = Mock()
     case.post_report = AsyncMock()
     exc = None
     try:
         raise SuiteFailed("foo")
     except SuiteFailed as e:
         exc = e
     with self.seconds_since_last_fail(case, now=now, failed=failed):
         case.status = initial_state
         await case.on_suite_fail(exc)
         assert case.status == State.FAIL
         assert case.last_fail == now
         if posts_report:
             case.log.exception.assert_called_once_with(str(exc))
             case.post_report.coro.assert_called_once_with(
                 TestReport(
                     case_name=case.name,
                     state=State.FAIL,
                     test=None,
                     runtime=None,
Exemplo n.º 2
0
 @pytest.mark.asyncio
 @pytest.mark.parametrize('initial_state,now,failed,posts_report', [
     (State.PASS, 300.0, 100.0, True),
     (State.PASS, 300.0, 290.0, False),
     (State.FAIL, 300.0, 290.0, False),
     (State.FAIL, 300.0, 100.0, True),
     (State.TIMEOUT, 300.0, 290.0, False),
     (State.TIMEOUT, 300.0, 100.0, True),
 ])
 async def test_on_suite_fail(self, initial_state, now, failed,
                              posts_report, *, case):
     case.log = Mock()
     case.post_report = AsyncMock()
     exc = None
     try:
         raise SuiteFailed('foo')
     except SuiteFailed as e:
         exc = e
     with self.seconds_since_last_fail(case, now=now, failed=failed):
         case.status = initial_state
         await case.on_suite_fail(exc)
         assert case.status == State.FAIL
         assert case.last_fail == now
         if posts_report:
             case.log.exception.assert_called_once_with(str(exc))
             case.post_report.coro.assert_called_once_with(
                 TestReport(
                     case_name=case.name,
                     state=State.FAIL,
                     test=None,
                     runtime=None,