()
| 173 | |
| 174 | #[test] |
| 175 | fn 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 | |
| 205 | fn datetime_to_timestamp(dt: &Bound<'_, PyAny>) -> PyResult<i64> { |
| 206 | let dt = dt.cast::<PyDateTime>()?; |
nothing calls this directly
no outgoing calls
no test coverage detected