Add a test showing that class attrs are immutable
This commit is contained in:
parent
7b5a076680
commit
8f22d10a14
|
@ -27,3 +27,11 @@ fn class_attributes() {
|
||||||
py_assert!(py, foo_obj, "foo_obj.a == 5");
|
py_assert!(py, foo_obj, "foo_obj.a == 5");
|
||||||
py_assert!(py, foo_obj, "foo_obj.B == 'bar'");
|
py_assert!(py, foo_obj, "foo_obj.B == 'bar'");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn class_attributes_are_immutable() {
|
||||||
|
let gil = Python::acquire_gil();
|
||||||
|
let py = gil.python();
|
||||||
|
let foo_obj = py.get_type::<Foo>();
|
||||||
|
py_expect_exception!(py, foo_obj, "foo_obj.a = 6", TypeError);
|
||||||
|
}
|
||||||
|
|
Loading…
Reference in New Issue