def test_sync_closed_loop(): loop = IOLoop.current() loop.close() IOLoop.clear_current() IOLoop.clear_instance() with pytest.raises(RuntimeError) as exc_info: sync(loop, inc, 1) exc_info.match("IOLoop is clos(ed|ing)")