diff options
author | Chris St. Pierre <chris.a.st.pierre@gmail.com> | 2012-08-22 09:28:01 -0400 |
---|---|---|
committer | Chris St. Pierre <chris.a.st.pierre@gmail.com> | 2012-08-22 09:28:01 -0400 |
commit | 74e4efe02266df2f1bb0459f3c6d2c048f53d58e (patch) | |
tree | 3cd34971f95eb881161043d8f20c209839556b5a /testsuite/common.py | |
parent | 094ddfe34e6c440c010935db4efa0c90b510d9fa (diff) | |
download | bcfg2-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.py | 12 |
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 |