From 9bb921c3ad36c946eb45803cd400ec6dded5704e Mon Sep 17 00:00:00 2001 From: Ben Cherry Date: Thu, 21 Nov 2024 16:15:28 -0800 Subject: [PATCH] split --- livekit-rtc/tests/test_emitter.py | 20 +++++++++++++------- 1 file changed, 13 insertions(+), 7 deletions(-) diff --git a/livekit-rtc/tests/test_emitter.py b/livekit-rtc/tests/test_emitter.py index f647baad..fb2616f3 100644 --- a/livekit-rtc/tests/test_emitter.py +++ b/livekit-rtc/tests/test_emitter.py @@ -53,26 +53,32 @@ def test_args(): args_calls = [] - @emitter.on("whatever_args") + @emitter.on("whatever") def on_whatever(first, second, third): args_calls.append((first, second, third)) - emitter.emit("whatever_args", 1, 2, 3) - emitter.emit("whatever_args", 1, 2, 3, 4, 5) # only 3 arguments will be passed + emitter.emit("whatever", 1, 2, 3) + emitter.emit("whatever", 1, 2, 3, 4, 5) # only 3 arguments will be passed assert args_calls == [(1, 2, 3), (1, 2, 3)] with pytest.raises(TypeError): - emitter.emit("whatever_args", 1, 2) + emitter.emit("whatever", 1, 2) + + +def test_varargs(): + EventTypes = Literal["whatever"] + + emitter = EventEmitter[EventTypes]() varargs_calls = [] - @emitter.on("whatever_varargs") + @emitter.on("whatever") def on_whatever_varargs(*args): varargs_calls.append(args) - emitter.emit("whatever_varargs", 1, 2, 3, 4, 5) - emitter.emit("whatever_varargs", 1, 2) + emitter.emit("whatever", 1, 2, 3, 4, 5) + emitter.emit("whatever", 1, 2) assert varargs_calls == [(1, 2, 3, 4, 5), (1, 2)]