Skip to content

Commit cba5497

Browse files
[3.14] gh-146059: Cleanup pickle fast_save_enter() test (GH-146481) (#146509)
gh-146059: Cleanup pickle fast_save_enter() test (GH-146481) Remove {"key": data}, it's not required to reproduce the bug. Simplify also deep_nested_struct(): remove the seed parameter. Fix a typo in a comment. (cherry picked from commit 0c7a75a) Co-authored-by: Victor Stinner <vstinner@python.org>
1 parent 4d61fd6 commit cba5497

File tree

1 file changed

+10
-14
lines changed

1 file changed

+10
-14
lines changed

Lib/test/pickletester.py

Lines changed: 10 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -4276,13 +4276,12 @@ def __reduce__(self):
42764276
self.assertIn(expected, str(e))
42774277

42784278
def fast_save_enter(self, create_data, minprotocol=0):
4279-
# gh-146059: Check that fast_save() is called when
4279+
# gh-146059: Check that fast_save_leave() is called when
42804280
# fast_save_enter() is called.
42814281
if not hasattr(self, "pickler"):
42824282
self.skipTest("need Pickler class")
42834283

42844284
data = [create_data(i) for i in range(FAST_NESTING_LIMIT * 2)]
4285-
data = {"key": data}
42864285
protocols = range(minprotocol, pickle.HIGHEST_PROTOCOL + 1)
42874286
for proto in protocols:
42884287
with self.subTest(proto=proto):
@@ -4316,18 +4315,17 @@ def test_fast_save_enter_frozendict(self):
43164315
def test_fast_save_enter_dict(self):
43174316
self.fast_save_enter(lambda i: {"key": i})
43184317

4319-
def deep_nested_struct(self, seed, create_nested,
4318+
def deep_nested_struct(self, create_nested,
43204319
minprotocol=0, compare_equal=True,
43214320
depth=FAST_NESTING_LIMIT * 2):
4322-
# gh-146059: Check that fast_save() is called when
4321+
# gh-146059: Check that fast_save_leave() is called when
43234322
# fast_save_enter() is called.
43244323
if not hasattr(self, "pickler"):
43254324
self.skipTest("need Pickler class")
43264325

4327-
data = seed
4326+
data = None
43284327
for i in range(depth):
43294328
data = create_nested(data)
4330-
data = {"key": data}
43314329
protocols = range(minprotocol, pickle.HIGHEST_PROTOCOL + 1)
43324330
for proto in protocols:
43334331
with self.subTest(proto=proto):
@@ -4343,29 +4341,27 @@ def deep_nested_struct(self, seed, create_nested,
43434341
self.assertEqual(data2, data)
43444342

43454343
def test_deep_nested_struct_tuple(self):
4346-
self.deep_nested_struct((1,), lambda data: (data,))
4344+
self.deep_nested_struct(lambda data: (data,))
43474345

43484346
def test_deep_nested_struct_list(self):
4349-
self.deep_nested_struct([1], lambda data: [data])
4347+
self.deep_nested_struct(lambda data: [data])
43504348

43514349
def test_deep_nested_struct_frozenset(self):
4352-
self.deep_nested_struct(frozenset((1,)),
4353-
lambda data: frozenset((1, data)))
4350+
self.deep_nested_struct(lambda data: frozenset((1, data)))
43544351

43554352
def test_deep_nested_struct_set(self):
4356-
self.deep_nested_struct({1}, lambda data: {K(data)},
4353+
self.deep_nested_struct(lambda data: {K(data)},
43574354
depth=FAST_NESTING_LIMIT+1,
43584355
compare_equal=False)
43594356

43604357
def test_deep_nested_struct_frozendict(self):
43614358
if self.py_version < (3, 15):
43624359
self.skipTest('need frozendict')
4363-
self.deep_nested_struct(frozendict(x=1),
4364-
lambda data: frozendict(x=data),
4360+
self.deep_nested_struct(lambda data: frozendict(x=data),
43654361
minprotocol=2)
43664362

43674363
def test_deep_nested_struct_dict(self):
4368-
self.deep_nested_struct({'x': 1}, lambda data: {'x': data})
4364+
self.deep_nested_struct(lambda data: {'x': data})
43694365

43704366

43714367
class BigmemPickleTests:

0 commit comments

Comments
 (0)