Exemplo n.º 1
0
def test_pass_in_retries(make_runner, make_cases, tmp_path, common_exec_ctx):
    tmpfile = tmp_path / 'out.txt'
    tmpfile.write_text('0\n')
    runner = make_runner(max_retries=3)
    pass_run_no = 2
    runner.runall(make_cases([RetriesCheck(pass_run_no, tmpfile)]))

    # Ensure that the test passed after retries in run `pass_run_no`
    assert 1 == runner.stats.num_cases()
    assert_runall(runner)
    assert 1 == len(runner.stats.failed(run=0))
    assert pass_run_no == rt.runtime().current_run
    assert 0 == len(runner.stats.failed())
Exemplo n.º 2
0
    def test_pass_in_retries(self):
        max_retries = 3
        run_to_pass = 2
        # Create a file containing the current_run; Run 0 will set it to 0,
        # run 1 to 1 and so on.
        with tempfile.NamedTemporaryFile(mode='wt', delete=False) as fp:
            fp.write('0\n')

        checks = [RetriesCheck(run_to_pass, fp.name)]
        self.runner._max_retries = max_retries
        self.runner.runall(checks)

        # Ensure that the test passed after retries in run #run_to_pass.
        self.assertEqual(1, self.runner.stats.num_cases())
        self.assertEqual(1, self.runner.stats.num_failures(run=0))
        self.assertEqual(run_to_pass, rt.runtime().current_run)
        self.assertEqual(0, self.runner.stats.num_failures())
        os.remove(fp.name)