Skip to content

Commit 53efedb

Browse files
author
Andrew J Westlake
committed
Re-exported inventory to simplify #[test] caveats
1 parent 83abceb commit 53efedb

File tree

3 files changed

+8
-8
lines changed

3 files changed

+8
-8
lines changed

pyo3-asyncio-macros/src/lib.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -248,7 +248,7 @@ pub fn tokio_test(_attr: TokenStream, item: TokenStream) -> TokenStream {
248248
let result = quote! {
249249
#fn_impl
250250

251-
inventory::submit!(pyo3_asyncio::testing::Test {
251+
pyo3_asyncio::inventory::submit!(pyo3_asyncio::testing::Test {
252252
name: format!("{}::{}", std::module_path!(), stringify!(#name)),
253253
test_fn: &#name
254254
});

src/lib.rs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -112,6 +112,10 @@ use futures::channel::oneshot;
112112
use once_cell::sync::OnceCell;
113113
use pyo3::{exceptions::PyKeyboardInterrupt, prelude::*, PyNativeType};
114114

115+
/// Re-exported for #[test] attributes
116+
#[cfg(all(feature = "attributes", feature = "testing"))]
117+
pub use inventory;
118+
115119
/// Test README
116120
#[doc(hidden)]
117121
pub mod doc_test {

src/testing.rs

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -60,13 +60,6 @@
6060
//! pyo3-asyncio = { version = "0.13", features = ["testing", "attributes", "async-std-runtime"] }
6161
//! ```
6262
//!
63-
//! In order for the `test_main!` macro to find your tests, you'll also need to add an extra
64-
//! `dev-dependency` for [`inventory`](https://github.com/dtolnay/inventory):
65-
//! ```toml
66-
//! [dev-dependencies]
67-
//! inventory = "0.1"
68-
//! ```
69-
//!
7063
//! At this point you should be able to run the test via `cargo test`
7164
//!
7265
//! ### Adding Tests to the PyO3 Asyncio Test Harness
@@ -346,13 +339,16 @@ pub async fn test_harness(tests: Vec<Test>, args: Args) -> PyResult<()> {
346339
/// # Examples
347340
///
348341
/// ```
342+
/// # #[cfg(all(feature = "async-std-runtime", feature = "attributes"))]
349343
/// use pyo3::prelude::*;
350344
///
351345
/// # #[cfg(all(feature = "async-std-runtime", feature = "attributes"))]
352346
/// #[pyo3_asyncio::async_std::main]
353347
/// async fn main() -> PyResult<()> {
354348
/// pyo3_asyncio::testing::main("Example Test Suite").await
355349
/// }
350+
/// # #[cfg(not(all(feature = "async-std-runtime", feature = "attributes")))]
351+
/// fn main() { }
356352
/// ```
357353
pub async fn main(suite_name: &str) -> PyResult<()> {
358354
let args = parse_args(suite_name);

0 commit comments

Comments
 (0)