Skip to content

Commit

Permalink
Add test for dir().
Browse files Browse the repository at this point in the history
  • Loading branch information
m-ou-se committed May 4, 2020
1 parent 36ebd05 commit d32c3c0
Showing 1 changed file with 18 additions and 0 deletions.
18 changes: 18 additions & 0 deletions src/objectprotocol.rs
Original file line number Diff line number Diff line change
Expand Up @@ -552,4 +552,22 @@ mod test {
let obj = py.eval("42", None, None).unwrap();
assert_eq!(unsafe { obj.get_type().as_type_ptr() }, obj.get_type_ptr())
}

#[test]
fn test_dir() {
let gil = Python::acquire_gil();
let py = gil.python();
let obj = py.eval("42", None, None).unwrap();
let dir = py
.eval("dir(42)", None, None)
.unwrap()
.extract::<&PyList>()
.unwrap();
let a = obj
.dir()
.into_iter()
.map(|x| x.extract::<String>().unwrap());
let b = dir.into_iter().map(|x| x.extract::<String>().unwrap());
assert!(a.eq(b));
}
}

0 comments on commit d32c3c0

Please sign in to comment.