()
| 427 | |
| 428 | #[test] |
| 429 | fn test_pycfunction_new() { |
| 430 | use pyo3::ffi; |
| 431 | |
| 432 | Python::attach(|py| { |
| 433 | unsafe extern "C" fn c_fn( |
| 434 | _self: *mut ffi::PyObject, |
| 435 | _args: *mut ffi::PyObject, |
| 436 | ) -> *mut ffi::PyObject { |
| 437 | unsafe { ffi::PyLong_FromLong(4200) } |
| 438 | } |
| 439 | |
| 440 | let py_fn = PyCFunction::new( |
| 441 | py, |
| 442 | c_fn, |
| 443 | c"py_fn", |
| 444 | c"py_fn for test (this is the docstring)", |
| 445 | None, |
| 446 | ) |
| 447 | .unwrap(); |
| 448 | |
| 449 | py_assert!(py, py_fn, "py_fn() == 4200"); |
| 450 | py_assert!( |
| 451 | py, |
| 452 | py_fn, |
| 453 | "py_fn.__doc__ == 'py_fn for test (this is the docstring)'" |
| 454 | ); |
| 455 | }); |
| 456 | } |
| 457 | |
| 458 | #[test] |
| 459 | fn test_pycfunction_new_with_keywords() { |
nothing calls this directly
no outgoing calls
no test coverage detected