Skip to content

Commit d32c3c0

Browse files
committed
Add test for dir().
1 parent 36ebd05 commit d32c3c0

File tree

1 file changed

+18
-0
lines changed

1 file changed

+18
-0
lines changed

src/objectprotocol.rs

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -552,4 +552,22 @@ mod test {
552552
let obj = py.eval("42", None, None).unwrap();
553553
assert_eq!(unsafe { obj.get_type().as_type_ptr() }, obj.get_type_ptr())
554554
}
555+
556+
#[test]
557+
fn test_dir() {
558+
let gil = Python::acquire_gil();
559+
let py = gil.python();
560+
let obj = py.eval("42", None, None).unwrap();
561+
let dir = py
562+
.eval("dir(42)", None, None)
563+
.unwrap()
564+
.extract::<&PyList>()
565+
.unwrap();
566+
let a = obj
567+
.dir()
568+
.into_iter()
569+
.map(|x| x.extract::<String>().unwrap());
570+
let b = dir.into_iter().map(|x| x.extract::<String>().unwrap());
571+
assert!(a.eq(b));
572+
}
555573
}

0 commit comments

Comments
 (0)