From 9333c619ffed8632820c25611fe987511990e6e8 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 82095e6cedb..47a54bae427 100644 --- a/tests/test_class_attributes.rs +++ b/tests/test_class_attributes.rs @@ -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::(); + py_expect_exception!(py, typeobj, "typeobj.foo = 6", TypeError); +}