def test_kernel_interrupt(): with run_kernel(make_sleep) as kernel: start = datetime.now() threading.Timer(1, interrupt).start() with pytest.raises(KeyboardInterrupt): kernel() end = datetime.now() assert end - start < timedelta(seconds=2)
def test_kernel(): kernel = run_kernel(make_double) with pytest.raises(Exception): kernel(1) with kernel: assert kernel(2) == 4 assert kernel(3) == 6 with pytest.raises(Exception): kernel(4) with kernel: kernel(5)
def test_kernel_death(): with run_kernel(make_kill_self) as kernel: with pytest.raises(KernelError): kernel()
def test_kernel_unpickleable(): with run_kernel(make_return_unpickleable) as kernel: assert kernel() is None
def test_kernel_exception(): with run_kernel(make_raise_exception) as kernel: assert kernel() is None