File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 22
33import copy
44import pickle
5+ import sys
56import unittest
7+ import warnings
68
79from collections import defaultdict
810
@@ -48,14 +50,16 @@ def test_basic(self):
4850 self .assertRaises (TypeError , defaultdict , 1 )
4951
5052 def test_missing (self ):
51- d1 = defaultdict ()
52- self .assertRaises (KeyError , d1 .__missing__ , 42 )
53- d1 .default_factory = list
54- v1 = d1 .__missing__ (42 )
55- self .assertEqual (v1 , [])
56- v2 = d1 .__missing__ (42 )
57- self .assertEqual (v2 , [])
58- self .assertIsNot (v2 , v1 )
53+ with warnings .catch_warnings (record = True , action = 'always' ) as w :
54+ d1 = defaultdict ()
55+ self .assertRaises (KeyError , d1 .__missing__ , 42 )
56+ d1 .default_factory = list
57+ v1 = d1 .__missing__ (42 )
58+ self .assertEqual (v1 , [])
59+ v2 = d1 .__missing__ (42 )
60+ self .assertEqual (v2 , [])
61+ self .assertIsNot (v2 , v1 )
62+ self .assertEqual (len (w ), 0 if sys ._is_gil_enabled () else 3 )
5963
6064 def test_repr (self ):
6165 d1 = defaultdict ()
You can’t perform that action at this time.
0 commit comments