Skip to content

Commit 7920807

Browse files
author
Andrew J Westlake
committed
Added test to verify #39
1 parent 85b4c08 commit 7920807

File tree

1 file changed

+18
-0
lines changed

1 file changed

+18
-0
lines changed

pytests/test_async_std_asyncio.rs

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,24 @@ async fn test_async_sleep() -> PyResult<()> {
5454
Ok(())
5555
}
5656

57+
#[pyo3_asyncio::async_std::test]
58+
async fn test_cancel() -> PyResult<()> {
59+
let py_future = Python::with_gil(|py| {
60+
pyo3_asyncio::async_std::into_coroutine(py, async {
61+
async_std::task::sleep(Duration::from_secs(1)).await;
62+
Ok(Python::with_gil(|py| py.None()))
63+
})
64+
})?;
65+
66+
Python::with_gil(|py| -> PyResult<_> {
67+
py_future.as_ref(py).call_method0("cancel")?;
68+
pyo3_asyncio::into_future(py_future.as_ref(py))
69+
})?
70+
.await?;
71+
72+
Ok(())
73+
}
74+
5775
#[pyo3_asyncio::async_std::test]
5876
fn test_blocking_sleep() -> PyResult<()> {
5977
common::test_blocking_sleep()

0 commit comments

Comments
 (0)