Skip to content

Commit 746d7d4

Browse files
author
Andrew J Westlake
committed
Added integration tests for other awaitables
1 parent c22d51a commit 746d7d4

File tree

3 files changed

+31
-0
lines changed

3 files changed

+31
-0
lines changed

pytests/common/mod.rs

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,3 +29,24 @@ pub(super) fn test_blocking_sleep() -> PyResult<()> {
2929
thread::sleep(Duration::from_secs(1));
3030
Ok(())
3131
}
32+
33+
pub(super) async fn test_other_awaitables() -> PyResult<()> {
34+
let fut = Python::with_gil(|py| {
35+
let functools = py.import("functools")?;
36+
let time = py.import("time")?;
37+
38+
let task = pyo3_asyncio::get_event_loop(py).call_method1(
39+
"run_in_executor",
40+
(
41+
py.None(),
42+
functools.call_method1("partial", (time.getattr("sleep")?, 1))?,
43+
),
44+
)?;
45+
46+
pyo3_asyncio::into_future(task)
47+
})?;
48+
49+
fut.await?;
50+
51+
Ok(())
52+
}

pytests/test_async_std_asyncio.rs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,11 @@ async fn test_into_future() -> PyResult<()> {
6464
common::test_into_future().await
6565
}
6666

67+
#[pyo3_asyncio::async_std::test]
68+
async fn test_other_awaitables() -> PyResult<()> {
69+
common::test_other_awaitables().await
70+
}
71+
6772
#[pyo3_asyncio::async_std::main]
6873
async fn main() -> pyo3::PyResult<()> {
6974
pyo3_asyncio::testing::main().await

pytests/tokio_asyncio/mod.rs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,3 +62,8 @@ fn test_blocking_sleep() -> PyResult<()> {
6262
async fn test_into_future() -> PyResult<()> {
6363
common::test_into_future().await
6464
}
65+
66+
#[pyo3_asyncio::tokio::test]
67+
async fn test_other_awaitables() -> PyResult<()> {
68+
common::test_other_awaitables().await
69+
}

0 commit comments

Comments
 (0)