diff options
author | Miss Islington (bot) <31488909+miss-islington@users.noreply.github.com> | 2022-11-07 10:16:54 (GMT) |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-11-07 10:16:54 (GMT) |
commit | ea2316a220ea5ae5646518e3855ef22b9c84d64d (patch) | |
tree | e1178ba32c93422d2ae696ef638a092bfdcd15d5 /Lib/test | |
parent | 1b5a62b88afd97475db7c4de72e65c08dd65d887 (diff) | |
download | cpython-ea2316a220ea5ae5646518e3855ef22b9c84d64d.zip cpython-ea2316a220ea5ae5646518e3855ef22b9c84d64d.tar.gz cpython-ea2316a220ea5ae5646518e3855ef22b9c84d64d.tar.bz2 |
[3.10] [ GH-99155: Fix `NormalDist` pickle with `0` and `1` protocols (GH-99156). (GH-99188) (GH-99190)
Diffstat (limited to 'Lib/test')
-rw-r--r-- | Lib/test/test_statistics.py | 11 |
1 files changed, 8 insertions, 3 deletions
diff --git a/Lib/test/test_statistics.py b/Lib/test/test_statistics.py index 2853b1b..341abef 100644 --- a/Lib/test/test_statistics.py +++ b/Lib/test/test_statistics.py @@ -2880,14 +2880,19 @@ class TestNormalDist: nd = NormalDist(100, 15) self.assertNotEqual(nd, lnd) - def test_pickle_and_copy(self): + def test_copy(self): nd = self.module.NormalDist(37.5, 5.625) nd1 = copy.copy(nd) self.assertEqual(nd, nd1) nd2 = copy.deepcopy(nd) self.assertEqual(nd, nd2) - nd3 = pickle.loads(pickle.dumps(nd)) - self.assertEqual(nd, nd3) + + def test_pickle(self): + nd = self.module.NormalDist(37.5, 5.625) + for proto in range(pickle.HIGHEST_PROTOCOL + 1): + with self.subTest(proto=proto): + pickled = pickle.loads(pickle.dumps(nd, protocol=proto)) + self.assertEqual(nd, pickled) def test_hashability(self): ND = self.module.NormalDist |