def test_get_error_fulfilled_promise(self): """Get the exception of a fulfilled Promise.""" def executor(on_fulfilled, on_rejected): on_fulfilled('result value') p = Promise(executor) assert p.exception() is None
def test_get_error_async_fulfilled_promise(self): """Get the exception of a Promise who will be fulfilled.""" def executor(on_fulfilled, on_rejected): Timer(0.001, on_fulfilled, args=[1]).start() p = Promise(executor) assert p.exception() is None
def test_get_error_async_rejected_promise(self): """Get the exception of a Promise soon to be rejected.""" class Err(Exception): pass def executor(on_fulfilled, on_rejected): Timer(0.001, on_rejected, args=[Err()]).start() p = Promise(executor) assert isinstance(p.exception(), Err)
def test_get_error_rejected_promise(self): """Get the exception of a rejected Promise.""" class Err(Exception): pass def executor(on_fulfilled, on_rejected): on_rejected(Err()) p = Promise(executor) err = p.exception() assert isinstance(err, Err)