diff options
author | Eric V. Smith <ericvsmith@users.noreply.github.com> | 2021-05-01 17:27:30 (GMT) |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-05-01 17:27:30 (GMT) |
commit | 823fbf4e0eb66cbef0eacb7e8dbfb5dc8ea83b40 (patch) | |
tree | cdbfea3d509837970384db1c0db0141014419c7a /Lib/test/test_dataclasses.py | |
parent | f82fd77717b58c97a16c05e25c72388b35860459 (diff) | |
download | cpython-823fbf4e0eb66cbef0eacb7e8dbfb5dc8ea83b40.zip cpython-823fbf4e0eb66cbef0eacb7e8dbfb5dc8ea83b40.tar.gz cpython-823fbf4e0eb66cbef0eacb7e8dbfb5dc8ea83b40.tar.bz2 |
If using a frozen class with slots, add __getstate__ and __setstate__ to set the instance values. (GH-25786)
Diffstat (limited to 'Lib/test/test_dataclasses.py')
-rw-r--r-- | Lib/test/test_dataclasses.py | 13 |
1 files changed, 13 insertions, 0 deletions
diff --git a/Lib/test/test_dataclasses.py b/Lib/test/test_dataclasses.py index 2fa0ae0..16ee4c7 100644 --- a/Lib/test/test_dataclasses.py +++ b/Lib/test/test_dataclasses.py @@ -2833,6 +2833,19 @@ class TestSlots(unittest.TestCase): self.assertFalse(hasattr(A, "__slots__")) self.assertTrue(hasattr(B, "__slots__")) + # Can't be local to test_frozen_pickle. + @dataclass(frozen=True, slots=True) + class FrozenSlotsClass: + foo: str + bar: int + + def test_frozen_pickle(self): + # bpo-43999 + + assert self.FrozenSlotsClass.__slots__ == ("foo", "bar") + p = pickle.dumps(self.FrozenSlotsClass("a", 1)) + assert pickle.loads(p) == self.FrozenSlotsClass("a", 1) + class TestDescriptors(unittest.TestCase): def test_set_name(self): |