MCPcopy Create free account
hub / github.com/PyO3/pyo3 / test_functions_with_function_args

Function test_functions_with_function_args

tests/test_pyfunction.rs:175–203  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

173
174#[test]
175fn test_functions_with_function_args() {
176 Python::attach(|py| {
177 let py_cfunc_arg = wrap_pyfunction!(function_with_pycfunction_arg)(py).unwrap();
178 let bool_to_string = wrap_pyfunction!(optional_bool)(py).unwrap();
179
180 pyo3::py_run!(
181 py,
182 py_cfunc_arg
183 bool_to_string,
184 r#"
185 assert py_cfunc_arg(bool_to_string) == "Some(true)"
186 "#
187 );
188
189 #[cfg(not(PyPy))]
190 {
191 let py_func_arg = wrap_pyfunction!(function_with_pyfunction_arg)(py).unwrap();
192
193 pyo3::py_run!(
194 py,
195 py_func_arg,
196 r#"
197 def foo(): return "bar"
198 assert py_func_arg(foo) == "bar"
199 "#
200 );
201 }
202 });
203}
204
205fn datetime_to_timestamp(dt: &Bound<'_, PyAny>) -> PyResult<i64> {
206 let dt = dt.cast::<PyDateTime>()?;

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected