From ab45b0bf88aa41c17c5cabe3cc8d0bee697ce5a0 Mon Sep 17 00:00:00 2001 From: Simon McVittie Date: Fri, 5 Oct 2012 13:21:16 +0100 Subject: [PATCH 4/8] enable_fakecm_account: copy parameters and alter the copy Mutable defaults for arguments are dangerous. If we call enable_fakecm_account twice with default arguments, when we alter expect_before_connect/expect_after_connect, we are actually altering the default! Python doesn't construct a new empty list for us every time. The C equivalent would be a static GPtrArray * or something. --- tests/twisted/mctest.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/tests/twisted/mctest.py b/tests/twisted/mctest.py index be187d6..e6eff4a 100644 --- a/tests/twisted/mctest.py +++ b/tests/twisted/mctest.py @@ -946,8 +946,12 @@ def expect_fakecm_connection(q, bus, mc, account, expected_params, has_requests=True, has_presence=False, has_aliasing=False, has_avatars=False, avatars_persist=True, extra_interfaces=[], - expect_before_connect=[], expect_after_connect=[], + expect_before_connect=(), expect_after_connect=(), has_hidden=False): + # make (safely) mutable copies + expect_before_connect = list(expect_before_connect) + expect_after_connect = list(expect_after_connect) + e = q.expect('dbus-method-call', method='RequestConnection', args=['fakeprotocol', expected_params], destination=cs.tp_name_prefix + '.ConnectionManager.fakecm', -- 1.7.10.4