()
| 244 | |
| 245 | #[test] |
| 246 | fn test_module_from_code_bound() { |
| 247 | Python::attach(|py| { |
| 248 | let adder_mod = PyModule::from_code( |
| 249 | py, |
| 250 | c"def add(a,b):\n\treturn a+b", |
| 251 | c"adder_mod.py", |
| 252 | &test_utils::generate_unique_module_name("adder_mod"), |
| 253 | ) |
| 254 | .expect("Module code should be loaded"); |
| 255 | |
| 256 | let add_func = adder_mod |
| 257 | .getattr("add") |
| 258 | .expect("Add function should be in the module"); |
| 259 | |
| 260 | let ret_value: i32 = add_func |
| 261 | .call1((1, 2)) |
| 262 | .expect("A value should be returned") |
| 263 | .extract() |
| 264 | .expect("The value should be able to be converted to an i32"); |
| 265 | |
| 266 | assert_eq!(ret_value, 3); |
| 267 | }); |
| 268 | } |
| 269 | |
| 270 | #[pyfunction] |
| 271 | fn r#move() -> usize { |
nothing calls this directly
no test coverage detected