Add a test showing that class attrs are immutable

This commit is contained in:
scalexm 2020-05-06 20:11:29 +02:00
parent 7b5a076680
commit 8f22d10a14
1 changed files with 8 additions and 0 deletions

View File

@ -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);
}