Skip to content

Commit

Permalink
add import_module_only integration test and fix span hygiene
Browse files Browse the repository at this point in the history
  • Loading branch information
MusicalNinjaDad committed Apr 18, 2024
1 parent 4651717 commit 4c1fced
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 2 deletions.
4 changes: 2 additions & 2 deletions pyo3-testing/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -139,11 +139,11 @@ fn wrap_testcase(testcase: Pyo3TestCase) -> TokenStream2 {
py_AttributeErrormsgs
.push("Failed to get ".to_string() + &py_functionname + " function");
py_functionidents.push(Ident::new(&py_functionname, Span::call_site()));
py_moduleswithfnsidents.push(Ident::new(&py_modulename, Span::mixed_site()));
py_moduleswithfnsidents.push(Ident::new(&py_modulename, Span::call_site()));
py_functionnames.push(py_functionname);
};
py_ModuleNotFoundErrormsgs.push("Failed to import ".to_string() + &py_modulename);
py_moduleidents.push(Ident::new(&py_modulename, Span::mixed_site()));
py_moduleidents.push(Ident::new(&py_modulename, Span::call_site()));
py_modulenames.push(py_modulename);
o3_moduleidents.push(import.o3_moduleident);
}
Expand Down
14 changes: 14 additions & 0 deletions tests/test_pyo3test.rs
Original file line number Diff line number Diff line change
Expand Up @@ -47,3 +47,17 @@ fn test_pyo3test_simple_case() {
let expected_result = 2_isize;
assert_eq!(result, expected_result);
}

#[pyo3test]
#[pyo3import(py_adders: import adders)]
fn test_pyo3test_import_module_only() {
let result: isize = adders
.getattr("addone")
.unwrap()
.call1((1_isize,))
.unwrap()
.extract()
.unwrap();
let expected_result = 2_isize;
assert_eq!(result, expected_result);
}

0 comments on commit 4c1fced

Please sign in to comment.