diff --git a/test/easyblocks/general.py b/test/easyblocks/general.py index 6638043853..813b9353a3 100644 --- a/test/easyblocks/general.py +++ b/test/easyblocks/general.py @@ -36,7 +36,7 @@ from easybuild.base.testing import TestCase from easybuild.easyblocks import VERSION from easybuild.tools.build_log import EasyBuildError -from easybuild.tools.run import run_cmd +from easybuild.tools.run import run_shell_cmd EASYBLOCK_BODY = """ @@ -62,11 +62,14 @@ def det_path_for_import(module, pythonpath=None): cmd = cmd_tmpl % {'mod': module} - out, _ = run_cmd(cmd, simple=False) + res = run_shell_cmd(cmd, hidden=True, fail_on_error=False) + + if res.exit_code: + raise EasyBuildError(res.output) # only return last line that should contain path to imported module # warning messages may precede it - return out.strip().split('\n')[-1] + return res.output.strip().split('\n')[-1] def up(path, level): @@ -134,7 +137,7 @@ def write_module(path, txt): self.assertTrue(os.path.samefile(easyblocks_path, parent_path), msg) # importing EB_R class from easybuild.easyblocks.r works fine - run_cmd("python -c 'from easybuild.easyblocks.r import EB_R'") + run_shell_cmd("python -c 'from easybuild.easyblocks.r import EB_R'", hidden=True) # importing a non-existing module fails err_msg = "No module named .*" @@ -163,7 +166,7 @@ def write_module(path, txt): self.assertTrue(os.path.samefile(repo_path, parent_path), msg) # importing EB_R class from easybuild.easyblocks.r still works fine - run_cmd("python -c 'from easybuild.easyblocks.r import EB_R'") + run_shell_cmd("python -c 'from easybuild.easyblocks.r import EB_R'", hidden=True) # custom easyblocks override existing easyblocks (with custom easyblocks repo first in $PYTHONPATH) for software in ['GCC', 'R']: @@ -175,7 +178,7 @@ def write_module(path, txt): self.assertTrue(os.path.samefile(custom_easyblocks_repo_path, parent_path), msg) # importing EB_R class from easybuild.easyblocks.r still works fine - run_cmd("python -c 'from easybuild.easyblocks.r import EB_R'") + run_shell_cmd("python -c 'from easybuild.easyblocks.r import EB_R'", hidden=True) def suite(): diff --git a/test/easyblocks/module.py b/test/easyblocks/module.py index ddd891a0cb..027578370f 100644 --- a/test/easyblocks/module.py +++ b/test/easyblocks/module.py @@ -181,7 +181,8 @@ def test_make_module_pythonpackage(self): print(which('python')) # create module file - app.make_module_step() + with self.mocked_stdout_stderr(): + app.make_module_step() remove_file(python) @@ -227,8 +228,8 @@ def test_pythonpackage_pick_python_cmd(self): """Test pick_python_cmd function from pythonpackage.py.""" from easybuild.easyblocks.generic.pythonpackage import pick_python_cmd self.assertTrue(pick_python_cmd() is not None) - self.assertTrue(pick_python_cmd(2) is not None) - self.assertTrue(pick_python_cmd(2, 6) is not None) + self.assertTrue(pick_python_cmd(3) is not None) + self.assertTrue(pick_python_cmd(3, 6) is not None) self.assertTrue(pick_python_cmd(123, 456) is None) @@ -356,7 +357,8 @@ def template_module_only_test(self, easyblock, name, version='1.3.2', extra_txt= # run all steps, most should be skipped orig_workdir = os.getcwd() try: - app.run_all_steps(run_test_cases=False) + with self.mocked_stdout_stderr(): + app.run_all_steps(run_test_cases=False) finally: change_dir(orig_workdir)