Ejemplo n.º 1
0
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)
Ejemplo n.º 2
0
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)
Ejemplo n.º 3
0
def test_kernel_death():
    with run_kernel(make_kill_self) as kernel:
        with pytest.raises(KernelError):
            kernel()
Ejemplo n.º 4
0
def test_kernel_unpickleable():
    with run_kernel(make_return_unpickleable) as kernel:
        assert kernel() is None
Ejemplo n.º 5
0
def test_kernel_exception():
    with run_kernel(make_raise_exception) as kernel:
        assert kernel() is None