1010class TestDefinition (unittest .TestCase ):
1111
1212 BIG_REFCOUNT = 1000
13+ FLAGS_REFCOUNT = 1
14+ FLAGS_NO_REFCOUNT = 0
15+ FLAGS_INVALID = - 1
1316
1417 def test_equivalence (self ):
1518 def run_with_refcount_check (self , func , obj ):
@@ -38,7 +41,7 @@ def run_with_refcount_check(self, func, obj):
3841 for func in funcs_with_incref + funcs_with_borrow :
3942 refcount , flags = run_with_refcount_check (self , func , obj )
4043 self .assertGreater (refcount , self .BIG_REFCOUNT )
41- self .assertIn (flags , (1 , - 1 ))
44+ self .assertIn (flags , (self . FLAGS_REFCOUNT , self . FLAGS_INVALID ))
4245 results .add ((refcount , flags ))
4346 self .assertEqual (len (results ), 1 )
4447
@@ -49,15 +52,15 @@ def run_with_refcount_check(self, func, obj):
4952 for func in funcs_with_incref :
5053 refcount , flags = run_with_refcount_check (self , func , obj )
5154 self .assertLess (refcount , self .BIG_REFCOUNT )
52- self .assertEqual (flags , 0 )
55+ self .assertEqual (flags , self . FLAGS_NO_REFCOUNT )
5356 results .add ((refcount , flags ))
5457 self .assertEqual (len (results ), 1 )
5558
5659 results = set ()
5760 for func in funcs_with_borrow :
5861 refcount , flags = run_with_refcount_check (self , func , obj )
5962 self .assertLess (refcount , self .BIG_REFCOUNT )
60- self .assertEqual (flags , 1 )
63+ self .assertEqual (flags , self . FLAGS_REFCOUNT )
6164 results .add ((refcount , flags ))
6265 self .assertEqual (len (results ), 1 )
6366
0 commit comments