@@ -34,26 +34,47 @@ def test_call_event_handler():
3434 def test_fn ():
3535 pass
3636
37+ test_fn .__qualname__ = "test_fn"
38+
3739 def test_fn_with_args (_ , arg1 , arg2 ):
3840 pass
3941
42+ test_fn_with_args .__qualname__ = "test_fn_with_args"
43+
4044 handler = EventHandler (fn = test_fn )
4145 event_spec = handler ()
4246
4347 assert event_spec .handler == handler
4448 assert event_spec .local_args == ()
4549 assert event_spec .args == ()
50+ assert format .format_event (event_spec ) == 'E("test_fn", {})'
4651
4752 handler = EventHandler (fn = test_fn_with_args )
4853 event_spec = handler (make_var ("first" ), make_var ("second" ))
4954
55+ # Test passing vars as args.
5056 assert event_spec .handler == handler
5157 assert event_spec .local_args == ()
5258 assert event_spec .args == (("arg1" , "first" ), ("arg2" , "second" ))
59+ assert (
60+ format .format_event (event_spec )
61+ == 'E("test_fn_with_args", {arg1:first,arg2:second})'
62+ )
63+
64+ # Passing args as strings should format differently.
65+ event_spec = handler ("first" , "second" ) # type: ignore
66+ assert (
67+ format .format_event (event_spec )
68+ == 'E("test_fn_with_args", {arg1:"first",arg2:"second"})'
69+ )
5370
5471 first , second = 123 , "456"
5572 handler = EventHandler (fn = test_fn_with_args )
5673 event_spec = handler (first , second ) # type: ignore
74+ assert (
75+ format .format_event (event_spec )
76+ == 'E("test_fn_with_args", {arg1:123,arg2:"456"})'
77+ )
5778
5879 assert event_spec .handler == handler
5980 assert event_spec .local_args == ()
0 commit comments