From 74e4efe02266df2f1bb0459f3c6d2c048f53d58e Mon Sep 17 00:00:00 2001 From: "Chris St. Pierre" Date: Wed, 22 Aug 2012 09:28:01 -0400 Subject: patchIf() adds arguments to function calls --- testsuite/common.py | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) (limited to 'testsuite') diff --git a/testsuite/common.py b/testsuite/common.py index 60165585d..cc5a67881 100644 --- a/testsuite/common.py +++ b/testsuite/common.py @@ -240,5 +240,15 @@ def patchIf(condition, entity, **kwargs): functions does not prevent the decorators from being run. """ if condition: return patch(entity, **kwargs) - else: + elif "new" in kwargs: + # new object provided, so no argument is added to the function call return lambda f: f + else: + # need to add an argument to the function call + def decorator(func): + @wraps(func) + def inner(*args, **kwargs): + args.pop() + return func(*args, **kwargs) + return inner + return decorator -- cgit v1.2.3-1-g7c22