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

Function test_pycfunction_new

tests/test_pyfunction.rs:429–456  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

427
428#[test]
429fn 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]
459fn test_pycfunction_new_with_keywords() {

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected