Fix test for python2

This commit is contained in:
konstin 2019-02-01 17:15:33 +01:00
parent c868cc3e4b
commit 328d61ca3b
1 changed files with 10 additions and 7 deletions

View File

@ -66,14 +66,17 @@ fn empty_class_in_module() {
ty.getattr("__name__").unwrap().extract::<String>().unwrap(),
"EmptyClassInModule"
);
let builtin = if cfg!(feature = "python2") {
"__builtin__"
} else {
"builtins"
};
let module: String = ty.getattr("__module__").unwrap().extract().unwrap();
// Rationale: The class can be added to many modules, but will only be initialized once.
// We currently have no way of determining a canonical module, so builtins is better
// than using whatever calls init first.
assert_eq!(
ty.getattr("__module__")
.unwrap()
.extract::<String>()
.unwrap(),
"builtins"
);
assert_eq!(module, builtin);
}