Skip to content

Commit 5f123a9

Browse files
committed
Add test case for callbacks with variable arguments
1 parent 7b6c8d3 commit 5f123a9

File tree

1 file changed

+14
-1
lines changed

1 file changed

+14
-1
lines changed

test/test_liblo.py

+14-1
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ def matchHost(host, regex):
2424

2525

2626
class Arguments:
27-
def __init__(self, path, args, types, src, data):
27+
def __init__(self, path, args, types=None, src=None, data=None):
2828
self.path = path
2929
self.args = args
3030
self.types = types
@@ -178,6 +178,19 @@ def testMethodAfterFree(self):
178178
with self.assertRaises(RuntimeError):
179179
self.server.recv()
180180

181+
def testCallbackVarargs(self):
182+
def foo(path, args, *varargs):
183+
self.cb = Arguments(path, args)
184+
self.cb_varargs = varargs
185+
self.server.add_method('/foo', 'f', foo, user_data='spam')
186+
self.server.send(1234, '/foo', 123.456)
187+
self.assertTrue(self.server.recv())
188+
self.assertEqual(self.cb.path, '/foo')
189+
self.assertAlmostEqual(self.cb.args[0], 123.456, places=3)
190+
self.assertEqual(self.cb_varargs[0], 'f')
191+
self.assertIsInstance(self.cb_varargs[1], liblo.Address)
192+
self.assertEqual(self.cb_varargs[2], 'spam')
193+
181194
def testBundleCallbacksFire(self):
182195
def bundle_start_cb(timestamp, user_data):
183196
self.assertIsInstance(timestamp, float)

0 commit comments

Comments
 (0)