MCPcopy Create free account
hub / github.com/dgrunwald/rust-cpython / instance_method_with_args

Function instance_method_with_args

tests/test_class.rs:233–247  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

231
232#[test]
233fn instance_method_with_args() {
234 let gil = Python::acquire_gil();
235 let py = gil.python();
236
237 let obj = InstanceMethodWithArgs::create_instance(py, 7).unwrap();
238 assert!(obj.method(py, 6).unwrap() == 42);
239 let d = PyDict::new(py);
240 d.set_item(py, "obj", obj).unwrap();
241 py.run("assert obj.method(3) == 21", None, Some(&d))
242 .unwrap();
243 py.run("assert obj.method(multiplier=6) == 42", None, Some(&d))
244 .unwrap();
245 py.run("assert obj.match(match=3) == 3", None, Some(&d))
246 .unwrap();
247}
248
249py_class!(class ClassMethod |py| {
250 def __new__(cls) -> PyResult<ClassMethod> {

Callers

nothing calls this directly

Calls 3

pythonMethod · 0.80
runMethod · 0.80
set_itemMethod · 0.45

Tested by

no test coverage detected