| 34 | |
| 35 | #[test] |
| 36 | fn instance_method() { |
| 37 | Python::attach(|py| { |
| 38 | let obj = Bound::new(py, InstanceMethod { member: 42 }).unwrap(); |
| 39 | let obj_ref = obj.borrow(); |
| 40 | assert_eq!(obj_ref.method(), 42); |
| 41 | py_assert!(py, obj, "obj.method() == 42"); |
| 42 | py_assert!(py, obj, "obj.add_other(obj) == 84"); |
| 43 | py_assert!(py, obj, "obj.method.__doc__ == 'Test method'"); |
| 44 | }); |
| 45 | } |
| 46 | |
| 47 | /// Test that CPython's method-wrapper descriptor rejects wrong receiver types |
| 48 | /// when `tp_methods` entries are called with a bad `self` from Python. |