()
| 580 | |
| 581 | #[test] |
| 582 | fn use_pyfunction() { |
| 583 | mod function_in_module { |
| 584 | use pyo3::prelude::*; |
| 585 | |
| 586 | #[pyfunction] |
| 587 | pub fn foo(x: i32) -> i32 { |
| 588 | x |
| 589 | } |
| 590 | } |
| 591 | |
| 592 | Python::attach(|py| { |
| 593 | use function_in_module::foo; |
| 594 | |
| 595 | // check imported name can be wrapped |
| 596 | let f = wrap_pyfunction!(foo, py).unwrap(); |
| 597 | assert_eq!(f.call1((5,)).unwrap().extract::<i32>().unwrap(), 5); |
| 598 | assert_eq!(f.call1((42,)).unwrap().extract::<i32>().unwrap(), 42); |
| 599 | |
| 600 | // check path import can be wrapped |
| 601 | let f2 = wrap_pyfunction!(function_in_module::foo, py).unwrap(); |
| 602 | assert_eq!(f2.call1((5,)).unwrap().extract::<i32>().unwrap(), 5); |
| 603 | assert_eq!(f2.call1((42,)).unwrap().extract::<i32>().unwrap(), 42); |
| 604 | }) |
| 605 | } |
| 606 | |
| 607 | #[pyclass] |
| 608 | struct Key(String); |
nothing calls this directly
no outgoing calls
no test coverage detected