File tree Expand file tree Collapse file tree 2 files changed +8
-0
lines changed Expand file tree Collapse file tree 2 files changed +8
-0
lines changed Original file line number Diff line number Diff line change @@ -37,6 +37,9 @@ cdef class CachedProperty(object):
37
37
PyDict_SetItem(cache, self .name, val)
38
38
return val
39
39
40
+ def __set__ (self , obj , value ):
41
+ raise AttributeError (" Can't set attribute" )
42
+
40
43
41
44
cache_readonly = CachedProperty
42
45
Original file line number Diff line number Diff line change @@ -2056,6 +2056,11 @@ def test_iadd_preserves_name(self):
2056
2056
ser .index -= 1
2057
2057
assert ser .index .name == "foo"
2058
2058
2059
+ def test_cached_properties_not_settable (self ):
2060
+ idx = pd .Index ([1 , 2 , 3 ])
2061
+ with tm .assert_raises_regex (AttributeError , "Can't set attribute" ):
2062
+ idx .is_unique = False
2063
+
2059
2064
2060
2065
class TestMixedIntIndex (Base ):
2061
2066
# Mostly the tests from common.py for which the results differ
You can’t perform that action at this time.
0 commit comments