Skip to content

Commit

Permalink
Add a test showing that class attrs are immutable
Browse files Browse the repository at this point in the history
  • Loading branch information
scalexm committed May 6, 2020
1 parent c41402d commit 9333c61
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions tests/test_class_attributes.rs
Original file line number Diff line number Diff line change
Expand Up @@ -27,3 +27,11 @@ fn class_attributes() {
py_assert!(py, typeobj, "typeobj.foo == 5");
py_assert!(py, typeobj, "typeobj.BAR == 'bar'");
}

#[test]
fn class_attributes_are_immutable() {
let gil = Python::acquire_gil();
let py = gil.python();
let typeobj = py.get_type::<Foo>();
py_expect_exception!(py, typeobj, "typeobj.foo = 6", TypeError);
}

0 comments on commit 9333c61

Please sign in to comment.