From 8f22d10a145ba8ad8f995c1ac8d869471ce379d3 Mon Sep 17 00:00:00 2001 From: scalexm Date: Wed, 6 May 2020 20:11:29 +0200 Subject: [PATCH] Add a test showing that class attrs are immutable --- tests/test_class_attributes.rs | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/tests/test_class_attributes.rs b/tests/test_class_attributes.rs index c5a36a2e..ab679c02 100644 --- a/tests/test_class_attributes.rs +++ b/tests/test_class_attributes.rs @@ -27,3 +27,11 @@ fn class_attributes() { py_assert!(py, foo_obj, "foo_obj.a == 5"); 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::(); + py_expect_exception!(py, foo_obj, "foo_obj.a = 6", TypeError); +}