@@ -154,29 +154,25 @@ def test_authorizer_invalid_signature(self):
154154 def test_authorizer_concurrent_mutation_in_call (self ):
155155 self .cx .execute ("create table if not exists test(a number)" )
156156
157- class Handler :
158- cx = self .cx
159- def __call__ (self , * a , ** kw ):
160- self .cx .set_authorizer (None )
161- raise ZeroDivisionError ("hello world" )
157+ def handler (* a , ** kw ):
158+ self .cx .set_authorizer (None )
159+ raise ZeroDivisionError ("hello world" )
162160
163- self .cx .set_authorizer (Handler () )
161+ self .cx .set_authorizer (handler )
164162 self .assert_not_authorized (self .cx .execute , "select * from test" )
165163
166164 @with_tracebacks (OverflowError )
167165 def test_authorizer_concurrent_mutation_with_overflown_value (self ):
168166 _testcapi = import_helper .import_module ("_testcapi" )
169167 self .cx .execute ("create table if not exists test(a number)" )
170168
171- class Handler :
172- cx = self .cx
173- def __call__ (self , * a , ** kw ):
174- self .cx .set_authorizer (None )
175- # We expect 'int' at the C level, so this one will raise
176- # when converting via PyLong_Int().
177- return _testcapi .INT_MAX + 1
178-
179- self .cx .set_authorizer (Handler ())
169+ def handler (* a , ** kw ):
170+ self .cx .set_authorizer (None )
171+ # We expect 'int' at the C level, so this one will raise
172+ # when converting via PyLong_Int().
173+ return _testcapi .INT_MAX + 1
174+
175+ self .cx .set_authorizer (handler )
180176 self .assert_not_authorized (self .cx .execute , "select * from test" )
181177
182178
@@ -294,21 +290,18 @@ def test_progress_handler_invalid_signature(self):
294290 def test_progress_handler_concurrent_mutation_in_call (self ):
295291 self .cx .execute ("create table if not exists test(a number)" )
296292
297- class Handler :
298- cx = self .cx
299- def __call__ (self , * a , ** kw ):
300- self .cx .set_progress_handler (None , 1 )
301- raise ZeroDivisionError ("hello world" )
293+ def handler (* a , ** kw ):
294+ self .cx .set_progress_handler (None , 1 )
295+ raise ZeroDivisionError ("hello world" )
302296
303- self .cx .set_progress_handler (Handler () , 1 )
297+ self .cx .set_progress_handler (handler , 1 )
304298 self .assert_interrupted (self .cx .execute , "select * from test" )
305299
306300 def test_progress_handler_concurrent_mutation_in_conversion (self ):
307301 self .cx .execute ("create table if not exists test(a number)" )
308302
309303 class Handler :
310- cx = self .cx
311- def __bool__ (self ):
304+ def __bool__ (_ ):
312305 # clear the progress handler
313306 self .cx .set_progress_handler (None , 1 )
314307 raise ValueError # force PyObject_True() to fail
@@ -466,14 +459,12 @@ def test_trace_handler_invalid_signature(self):
466459 def test_trace_callback_concurrent_mutation_in_call (self ):
467460 self .cx .execute ("create table if not exists test(a number)" )
468461
469- class Handler :
470- cx = self .cx
471- def __call__ (self , statement ):
472- # clear the progress handler
473- self .cx .set_trace_callback (None )
474- raise ZeroDivisionError ("hello world" )
462+ def handler (statement ):
463+ # clear the progress handler
464+ self .cx .set_trace_callback (None )
465+ raise ZeroDivisionError ("hello world" )
475466
476- self .cx .set_trace_callback (Handler () )
467+ self .cx .set_trace_callback (handler )
477468 self .cx .execute ("select * from test" )
478469
479470
0 commit comments