diff --git a/nipype/interfaces/base/tests/test_resource_monitor.py b/nipype/interfaces/base/tests/test_resource_monitor.py index f82a82661d..d40ecbebde 100644 --- a/nipype/interfaces/base/tests/test_resource_monitor.py +++ b/nipype/interfaces/base/tests/test_resource_monitor.py @@ -18,10 +18,16 @@ from ... import utility as niu # Try to enable the resource monitor -config.enable_resource_monitor() run_profile = config.resource_monitor +@pytest.fixture(scope="module") +def use_resource_monitor(): + config.enable_resource_monitor() + yield + config.disable_resource_monitor() + + class UseResourcesInputSpec(CommandLineInputSpec): mem_gb = traits.Float( desc='Number of GB of RAM to use', argstr='-g %f', mandatory=True) @@ -51,7 +57,7 @@ class UseResources(CommandLine): os.getenv('CI_SKIP_TEST', False), reason='disabled in CI tests') @pytest.mark.parametrize("mem_gb,n_procs", [(0.5, 3), (2.2, 8), (0.8, 4), (1.5, 1)]) -def test_cmdline_profiling(tmpdir, mem_gb, n_procs): +def test_cmdline_profiling(tmpdir, mem_gb, n_procs, use_resource_monitor): """ Test runtime profiler correctly records workflow RAM/CPUs consumption of a CommandLine-derived interface @@ -73,7 +79,7 @@ def test_cmdline_profiling(tmpdir, mem_gb, n_procs): True, reason='test disabled temporarily, until funcion profiling works') @pytest.mark.parametrize("mem_gb,n_procs", [(0.5, 3), (2.2, 8), (0.8, 4), (1.5, 1)]) -def test_function_profiling(tmpdir, mem_gb, n_procs): +def test_function_profiling(tmpdir, mem_gb, n_procs, use_resource_monitor): """ Test runtime profiler correctly records workflow RAM/CPUs consumption of a Function interface diff --git a/nipype/utils/config.py b/nipype/utils/config.py index e4e518960c..79c0bf6b51 100644 --- a/nipype/utils/config.py +++ b/nipype/utils/config.py @@ -291,6 +291,10 @@ def enable_resource_monitor(self): """Sets the resource monitor on""" self.resource_monitor = True + def disable_resource_monitor(self): + """Sets the resource monitor off""" + self.resource_monitor = False + def get_display(self): """Returns the first display available"""