@@ -51,35 +51,30 @@ def test_args():
5151
5252 emitter = EventEmitter [EventTypes ]()
5353
54- calls = []
54+ args_calls = []
5555
56- @emitter .on ("whatever " )
56+ @emitter .on ("whatever_args " )
5757 def on_whatever (first , second , third ):
58- calls .append ((first , second , third ))
58+ args_calls .append ((first , second , third ))
5959
60- emitter .emit ("whatever " , 1 , 2 , 3 )
61- emitter .emit ("whatever " , 1 , 2 , 3 , 4 , 5 ) # only 3 arguments will be passed
60+ emitter .emit ("whatever_args " , 1 , 2 , 3 )
61+ emitter .emit ("whatever_args " , 1 , 2 , 3 , 4 , 5 ) # only 3 arguments will be passed
6262
63- assert len (calls ) == 2
64- assert calls [0 ] == (1 , 2 , 3 )
65- assert calls [1 ] == (1 , 2 , 3 )
66-
67- calls = []
63+ assert args_calls == [(1 , 2 , 3 ), (1 , 2 , 3 )]
6864
6965 with pytest .raises (TypeError ):
70- emitter .emit ("whatever " , 1 , 2 )
66+ emitter .emit ("whatever_args " , 1 , 2 )
7167
72- assert len ( calls ) == 0
68+ varargs_calls = []
7369
74- @emitter .on ("whatever " )
70+ @emitter .on ("whatever_varargs " )
7571 def on_whatever_varargs (* args ):
76- calls .append (args )
72+ varargs_calls .append (args )
7773
78- emitter .emit ("whatever" , 1 , 2 , 3 , 4 , 5 )
74+ emitter .emit ("whatever_varargs" , 1 , 2 , 3 , 4 , 5 )
75+ emitter .emit ("whatever_varargs" , 1 , 2 )
7976
80- assert len (calls ) == 2
81- assert calls [0 ] == (1 , 2 , 3 )
82- assert calls [1 ] == (1 , 2 , 3 , 4 , 5 )
77+ assert varargs_calls == [(1 , 2 , 3 , 4 , 5 ), (1 , 2 )]
8378
8479
8580def test_throw ():
0 commit comments