@@ -323,7 +323,7 @@ def check_add_method(self, add_method):
323323 items = self .create_items (self .PySet_MINSIZE * 2 - 1 )
324324 table_size = self .compute_table_size (len (items ))
325325 for prealloc in (0 , len (items ) // 2 , len (items ), len (items ) * 10 ):
326- with self .subTest (size = prealloc ):
326+ with self .subTest (prealloc = prealloc ):
327327 writer = self .create_writer ()
328328 add = getattr (writer , add_method )
329329 for item in items :
@@ -356,7 +356,7 @@ def check_update_method(self, update_method):
356356 empty = ()
357357
358358 for prealloc in (0 , total // 2 , total , total * 10 ):
359- with self .subTest (size = prealloc ):
359+ with self .subTest (prealloc = prealloc ):
360360 writer = self .create_writer (prealloc )
361361 update = getattr (writer , update_method )
362362 update (items + common )
@@ -412,10 +412,21 @@ class MyObject:
412412
413413 def test_discard (self ):
414414 # Test PyFrozenSetWriter_Discard(): must not leak memory
415- writer = self . create_writer ()
416- writer . update ([ 2 , 5 , 7 ] )
415+
416+ writer = self . create_writer ( 0 )
417417 writer .discard ()
418418
419+ for prealloc in (0 , 3 , 100 ):
420+ for items in (
421+ (), # empty
422+ [2 , 5 , 7 ], # use the small table
423+ range (100 ), # allocate a new table
424+ ):
425+ with self .subTest (prealloc = prealloc , items = items ):
426+ writer = self .create_writer (prealloc )
427+ writer .update (items )
428+ writer .discard ()
429+
419430 @threading_helper .requires_working_threading ()
420431 def test_thread (self ):
421432 # PyFrozenSetWriter can be used by multiple threads: it's up to the
0 commit comments