Attribute Macro pyo3_asyncio_macros::tokio_test [−][src]
#[tokio_test]
Registers a tokio
test with the pyo3-asyncio
test harness.
This attribute is meant to mirror the #[test]
attribute and allow you to mark a function for
testing within an integration test. Like the #[tokio::test]
attribute, it will accept async
test functions, but it will also accept blocking functions as well.
Examples
ⓘ
use std::{time::Duration, thread}; use pyo3::prelude::*; // async test function #[pyo3_asyncio::tokio::test] async fn test_async_sleep() -> PyResult<()> { tokio::time::sleep(Duration::from_secs(1)).await; Ok(()) } // blocking test function #[pyo3_asyncio::tokio::test] fn test_blocking_sleep() -> PyResult<()> { thread::sleep(Duration::from_secs(1)); Ok(()) }