def test_with_custom_exception_instance():
    exc = ValueError("an instance of an excepiton")
    timeout = Timeout(0.01, exc)
    timeout.start()
    time.sleep(0.02)
    with pytest.raises(ValueError) as err:
        timeout.check()

    assert err.value is exc
def test_inline_timeout():
    timeout = Timeout(0.01)
    timeout.start()
    time.sleep(0.02)
    with pytest.raises(Timeout):
        timeout.check()
def test_with_custom_exception_type():
    timeout = Timeout(0.01, ValueError)
    timeout.start()
    time.sleep(0.02)
    with pytest.raises(ValueError):
        timeout.check()
def test_inline_completion_before_timeout():
    timeout = Timeout(0.01)
    timeout.start()
    timeout.check()
    timeout.cancel()
    time.sleep(0.02)