1use pyo3::prelude::*;
2use pyo3::types::PyDict;
3use pyo3::wrap_pymodule;
4
5pub mod awaitable;
6pub mod buf_and_str;
7pub mod comparisons;
8pub mod datetime;
9pub mod dict_iter;
10pub mod enums;
11pub mod misc;
12pub mod objstore;
13pub mod othermod;
14pub mod path;
15pub mod pyclasses;
16pub mod pyfunctions;
17pub mod sequence;
18pub mod subclassing;
19
20#[pymodule(gil_used = false)]
21mod pyo3_pytests {
22 use super::*;
23
24 #[pymodule_export]
25 use {pyclasses::pyclasses, pyfunctions::pyfunctions};
26
27 #[pymodule_init]
30 fn init(m: &Bound<'_, PyModule>) -> PyResult<()> {
31 m.add_wrapped(wrap_pymodule!(awaitable::awaitable))?;
32 #[cfg(not(Py_LIMITED_API))]
33 m.add_wrapped(wrap_pymodule!(buf_and_str::buf_and_str))?;
34 m.add_wrapped(wrap_pymodule!(comparisons::comparisons))?;
35 #[cfg(not(Py_LIMITED_API))]
36 m.add_wrapped(wrap_pymodule!(datetime::datetime))?;
37 m.add_wrapped(wrap_pymodule!(dict_iter::dict_iter))?;
38 m.add_wrapped(wrap_pymodule!(enums::enums))?;
39 m.add_wrapped(wrap_pymodule!(misc::misc))?;
40 m.add_wrapped(wrap_pymodule!(objstore::objstore))?;
41 m.add_wrapped(wrap_pymodule!(othermod::othermod))?;
42 m.add_wrapped(wrap_pymodule!(path::path))?;
43 m.add_wrapped(wrap_pymodule!(sequence::sequence))?;
44 m.add_wrapped(wrap_pymodule!(subclassing::subclassing))?;
45
46 let sys = PyModule::import(m.py(), "sys")?;
50 let sys_modules = sys.getattr("modules")?.downcast_into::<PyDict>()?;
51 sys_modules.set_item("pyo3_pytests.awaitable", m.getattr("awaitable")?)?;
52 sys_modules.set_item("pyo3_pytests.buf_and_str", m.getattr("buf_and_str")?)?;
53 sys_modules.set_item("pyo3_pytests.comparisons", m.getattr("comparisons")?)?;
54 sys_modules.set_item("pyo3_pytests.datetime", m.getattr("datetime")?)?;
55 sys_modules.set_item("pyo3_pytests.dict_iter", m.getattr("dict_iter")?)?;
56 sys_modules.set_item("pyo3_pytests.enums", m.getattr("enums")?)?;
57 sys_modules.set_item("pyo3_pytests.misc", m.getattr("misc")?)?;
58 sys_modules.set_item("pyo3_pytests.objstore", m.getattr("objstore")?)?;
59 sys_modules.set_item("pyo3_pytests.othermod", m.getattr("othermod")?)?;
60 sys_modules.set_item("pyo3_pytests.path", m.getattr("path")?)?;
61 sys_modules.set_item("pyo3_pytests.pyclasses", m.getattr("pyclasses")?)?;
62 sys_modules.set_item("pyo3_pytests.pyfunctions", m.getattr("pyfunctions")?)?;
63 sys_modules.set_item("pyo3_pytests.sequence", m.getattr("sequence")?)?;
64 sys_modules.set_item("pyo3_pytests.subclassing", m.getattr("subclassing")?)?;
65
66 Ok(())
67 }
68}