summaryrefslogtreecommitdiffstats
path: root/testsuite/common.py
diff options
context:
space:
mode:
authorChris St. Pierre <chris.a.st.pierre@gmail.com>2012-08-22 09:28:01 -0400
committerChris St. Pierre <chris.a.st.pierre@gmail.com>2012-08-22 09:28:01 -0400
commit74e4efe02266df2f1bb0459f3c6d2c048f53d58e (patch)
tree3cd34971f95eb881161043d8f20c209839556b5a /testsuite/common.py
parent094ddfe34e6c440c010935db4efa0c90b510d9fa (diff)
downloadbcfg2-74e4efe02266df2f1bb0459f3c6d2c048f53d58e.tar.gz
bcfg2-74e4efe02266df2f1bb0459f3c6d2c048f53d58e.tar.bz2
bcfg2-74e4efe02266df2f1bb0459f3c6d2c048f53d58e.zip
patchIf() adds arguments to function calls
Diffstat (limited to 'testsuite/common.py')
-rw-r--r--testsuite/common.py12
1 files changed, 11 insertions, 1 deletions
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