Example #1
0
def test_kbd_interrupt_within_test(make_runner, make_cases, common_exec_ctx):
    runner = make_runner()
    check = KeyboardInterruptCheck()
    with pytest.raises(KeyboardInterrupt):
        runner.runall(make_cases([KeyboardInterruptCheck()]))

    stats = runner.stats
    assert 1 == len(stats.failed())
    assert_all_dead(runner)
Example #2
0
def test_kbd_interrupt_in_wait_with_limited_concurrency(
        async_runner, make_cases, make_async_exec_ctx):
    # The general idea for this test is to allow enough time for all the
    # four checks to be submitted and at the same time we need the
    # KeyboardInterruptCheck to finish first (the corresponding wait should
    # trigger the failure), so as to make the framework kill the remaining
    # three.
    ctx = make_async_exec_ctx(2)
    next(ctx)

    runner, _ = async_runner
    with pytest.raises(KeyboardInterrupt):
        runner.runall(
            make_cases([
                KeyboardInterruptCheck(),
                SleepCheck(10),
                SleepCheck(10),
                SleepCheck(10)
            ]))
        # FIXME: Dump everything in case Github #1369 appears
        print(util.repr(runner))
        print(runner.stats.failure_report())
        print(util.repr(rt.runtime().site_config))

    assert_interrupted_run(runner)
Example #3
0
 def test_kbd_interrupt_in_setup_with_limited_concurrency(self):
     checks = [
         SleepCheck(1),
         SleepCheck(1),
         SleepCheck(1),
         KeyboardInterruptCheck(phase='setup')
     ]
     self._run_checks(checks, 2)
Example #4
0
 def test_kbd_interrupt_in_wait_with_concurrency(self):
     checks = [
         KeyboardInterruptCheck(),
         SleepCheck(10),
         SleepCheck(10),
         SleepCheck(10)
     ]
     self._run_checks(checks, 4)
Example #5
0
    def test_kbd_interrupt_within_test(self):
        check = KeyboardInterruptCheck()
        with pytest.raises(KeyboardInterrupt):
            self.runall([check])

        stats = self.runner.stats
        assert 1 == len(stats.failures())
        self.assert_all_dead()
Example #6
0
 def test_kbd_interrupt_in_wait_with_limited_concurrency(self):
     # The general idea for this test is to allow enough time for all the
     # four checks to be submitted and at the same time we need the
     # KeyboardInterruptCheck to finish first (the corresponding wait should
     # trigger the failure), so as to make the framework kill the remaining
     # three.
     checks = [KeyboardInterruptCheck(),
               SleepCheck(10), SleepCheck(10), SleepCheck(10)]
     self._run_checks(checks, 2)
Example #7
0
def test_kbd_interrupt_in_setup_with_limited_concurrency(
        async_runner, make_cases, make_async_exec_ctx):
    ctx = make_async_exec_ctx(2)
    next(ctx)

    runner, _ = async_runner
    with pytest.raises(KeyboardInterrupt):
        runner.runall(make_cases([
            SleepCheck(1), SleepCheck(1), SleepCheck(1),
            KeyboardInterruptCheck(phase='setup')
        ]))

    assert_interrupted_run(runner)
Example #8
0
def test_kbd_interrupt_in_wait_with_concurrency(async_runner, make_cases,
                                                make_async_exec_ctx):
    ctx = make_async_exec_ctx(4)
    next(ctx)

    runner, _ = async_runner
    with pytest.raises(KeyboardInterrupt):
        runner.runall(make_cases([
            KeyboardInterruptCheck(), SleepCheck(10),
            SleepCheck(10), SleepCheck(10)
        ]))

    assert_interrupted_run(runner)
Example #9
0
def test_kbd_interrupt_in_setup_with_concurrency(async_runner, make_cases,
                                                 make_exec_ctx):
    make_exec_ctx(options=max_jobs_opts(4))
    runner, _ = async_runner
    with pytest.raises(KeyboardInterrupt):
        runner.runall(
            make_cases([
                SleepCheck(1),
                SleepCheck(1),
                SleepCheck(1),
                KeyboardInterruptCheck(phase='setup')
            ]))

    assert_interrupted_run(runner)
Example #10
0
def test_kbd_interrupt_in_wait_with_limited_concurrency(
        async_runner, make_cases, make_async_exec_ctx):
    # The general idea for this test is to allow enough time for all the
    # four checks to be submitted and at the same time we need the
    # KeyboardInterruptCheck to finish first (the corresponding wait should
    # trigger the failure), so as to make the framework kill the remaining
    # three.
    ctx = make_async_exec_ctx(2)
    next(ctx)

    runner, _ = async_runner
    with pytest.raises(KeyboardInterrupt):
        runner.runall(make_cases([
            KeyboardInterruptCheck(), SleepCheck(10),
            SleepCheck(10), SleepCheck(10)
        ]))

    assert_interrupted_run(runner)
Example #11
0
 def test_kbd_interrupt_within_test(self):
     check = KeyboardInterruptCheck()
     self.assertRaises(KeyboardInterrupt, self.runner.runall, [check])
     stats = self.runner.stats
     self.assertEqual(1, stats.num_failures())
     self.assert_all_dead()