| 231 | |
| 232 | #[test] |
| 233 | fn 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 | |
| 249 | py_class!(class ClassMethod |py| { |
| 250 | def __new__(cls) -> PyResult<ClassMethod> { |