From 28fd80c17caee8169832c46073aee5d01fe1bec0 Mon Sep 17 00:00:00 2001 From: Martin Craig <martin.craig@eng.ox.ac.uk> Date: Wed, 24 Oct 2018 19:29:48 +0100 Subject: [PATCH] Allow the mock FSLDIR to create dummy files in specified subdirectories This is because the logic for selecting a command now checks for a file actually existing in FSLDEVDIR, FSLDIR etc, so we need to make sure a corresponding file actually exists before doing a command line wrapper test --- tests/__init__.py | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/tests/__init__.py b/tests/__init__.py index 4960e9095..06bd6b5b7 100644 --- a/tests/__init__.py +++ b/tests/__init__.py @@ -35,7 +35,7 @@ logging.getLogger().setLevel(logging.WARNING) @contextlib.contextmanager -def mockFSLDIR(): +def mockFSLDIR(**kwargs): oldfsldir = fslplatform.fsldir oldfsldevdir = fslplatform.fsldevdir @@ -45,6 +45,12 @@ def mockFSLDIR(): fsldir = op.join(td, 'fsl') bindir = op.join(fsldir, 'bin') os.makedirs(bindir) + for subdir, files in kwargs.items(): + subdir = op.join(fsldir, subdir) + if not op.isdir(subdir): + os.makedirs(subdir) + for fname in files: + touch(op.join(subdir, fname)) fslplatform.fsldir = fsldir fslplatform.fsldevdir = None -- GitLab