Added a test that call call_method with kwargs

This commit is contained in:
kngwyu 2018-10-31 15:23:18 +09:00
parent 607c23d287
commit 625a3f6738

View file

@ -496,7 +496,7 @@ mod test {
use conversion::{PyTryFrom, ToPyObject}; use conversion::{PyTryFrom, ToPyObject};
use instance::AsPyRef; use instance::AsPyRef;
use python::Python; use python::Python;
use types::PyString; use types::{IntoPyDict, PyString};
#[test] #[test]
fn test_debug_string() { fn test_debug_string() {
@ -527,6 +527,16 @@ mod test {
assert!(a.call_method1("nonexistent_method", (1,)).is_err()); assert!(a.call_method1("nonexistent_method", (1,)).is_err());
} }
#[test]
fn test_call_with_kwargs() {
let gil = Python::acquire_gil();
let py = gil.python();
let list = py.eval("list([3, 6, 5, 4, 7])", None, None).unwrap();
let dict = vec![("reverse", true)].into_py_dict(py);
list.call_method("sort", (), Some(dict)).unwrap();
assert_eq!(list.extract::<Vec<i32>>().unwrap(), vec![7, 6, 5, 4, 3]);
}
#[test] #[test]
fn test_type() { fn test_type() {
let gil = Python::acquire_gil(); let gil = Python::acquire_gil();