summaryrefslogtreecommitdiff
path: root/tests/unittests/helpers.py
diff options
context:
space:
mode:
authorLars Kellogg-Stedman <lars@redhat.com>2015-06-03 13:16:23 -0400
committerLars Kellogg-Stedman <lars@redhat.com>2015-06-03 13:16:23 -0400
commit2a955375dbf0d546d8999793923c4e8f23e042c6 (patch)
treed6898742505749642401d2e0ac7b13784ea35db8 /tests/unittests/helpers.py
parent04a5edaa33d6a7e64f95c04eceaa82eec12cb237 (diff)
downloadvyos-cloud-init-2a955375dbf0d546d8999793923c4e8f23e042c6.tar.gz
vyos-cloud-init-2a955375dbf0d546d8999793923c4e8f23e042c6.zip
transform paths in functions taking more than a single argument
Patch FilesystemMockingTestcase.patchOS to support methods taking more than a single path argument. This is required in order to properly mock `os.symlink`, which takes two path arguments.
Diffstat (limited to 'tests/unittests/helpers.py')
-rw-r--r--tests/unittests/helpers.py10
1 files changed, 6 insertions, 4 deletions
diff --git a/tests/unittests/helpers.py b/tests/unittests/helpers.py
index 61a1f6ff..7f4b8784 100644
--- a/tests/unittests/helpers.py
+++ b/tests/unittests/helpers.py
@@ -248,13 +248,15 @@ class FilesystemMockingTestCase(ResourceUsingTestCase):
def patchOS(self, new_root):
patch_funcs = {
- os.path: ['isfile', 'exists', 'islink', 'isdir'],
- os: ['listdir'],
+ os.path: [('isfile', 1), ('exists', 1),
+ ('islink', 1), ('isdir', 1)],
+ os: [('listdir', 1), ('mkdir', 1),
+ ('lstat', 1), ('symlink', 2)],
}
for (mod, funcs) in patch_funcs.items():
- for f in funcs:
+ for f, nargs in funcs:
func = getattr(mod, f)
- trap_func = retarget_many_wrapper(new_root, 1, func)
+ trap_func = retarget_many_wrapper(new_root, nargs, func)
self.patched_funcs.enter_context(
mock.patch.object(mod, f, trap_func))