Skip to content

Commit 1c8f7b9

Browse files
Add another test
1 parent 883363f commit 1c8f7b9

File tree

1 file changed

+14
-0
lines changed

1 file changed

+14
-0
lines changed

Lib/test/test_dataclasses/__init__.py

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3076,6 +3076,20 @@ class C:
30763076
with self.assertRaises(FrozenInstanceError):
30773077
del c.i
30783078

3079+
def test_frozen_slotted(self):
3080+
# See https://github.com/python/cpython/pull/144021
3081+
@dataclass(frozen=True, slots=True)
3082+
class C:
3083+
pass
3084+
3085+
c = C()
3086+
# Mutating not defined fields must raise FrozenInstanceError.
3087+
with self.assertRaises(FrozenInstanceError):
3088+
c.any_field = 5
3089+
3090+
with self.assertRaises(FrozenInstanceError):
3091+
del c.any_field
3092+
30793093
def test_inherit(self):
30803094
@dataclass(frozen=True)
30813095
class C:

0 commit comments

Comments
 (0)