From da9e66c42fbd3f67c430b77bd53cc4103f1cba6b Mon Sep 17 00:00:00 2001 From: Nig3l Date: Mon, 11 Nov 2024 16:08:25 +0100 Subject: [PATCH] Fix flake8 report Signed-off-by: Nig3l --- src/rez/plugin_managers.py | 8 +++++--- src/rez/tests/test_plugin_manager.py | 10 +++++----- src/rez/tests/util.py | 8 ++++---- 3 files changed, 14 insertions(+), 12 deletions(-) diff --git a/src/rez/plugin_managers.py b/src/rez/plugin_managers.py index 6cd3af1b6..e561f8087 100644 --- a/src/rez/plugin_managers.py +++ b/src/rez/plugin_managers.py @@ -210,9 +210,11 @@ def register_plugin_module(self, plugin_name, plugin_module, plugin_path): plugin_class = plugin_module.register_plugin() if plugin_class is not None: - self.register_plugin(plugin_name, - plugin_class, - plugin_module) + self.register_plugin( + plugin_name, + plugin_class, + plugin_module + ) else: if config.debug("plugins"): print_warning( diff --git a/src/rez/tests/test_plugin_manager.py b/src/rez/tests/test_plugin_manager.py index a92def4fe..906d3d3ff 100644 --- a/src/rez/tests/test_plugin_manager.py +++ b/src/rez/tests/test_plugin_manager.py @@ -50,7 +50,7 @@ def setUp(self): TestBase.setUp(self) self._reset_plugin_manager() - def _test_load_plugin_from_plugin_path(self): + def test_load_plugin_from_plugin_path(self): """Test loading rez plugin from plugin_path""" self.update_settings(dict( plugin_path=[self.data_path("extensions", "foo")] @@ -60,7 +60,7 @@ def _test_load_plugin_from_plugin_path(self): "package_repository", "cloud") self.assertEqual(cloud_cls.name(), "cloud") - def _test_load_plugin_from_python_module(self): + def test_load_plugin_from_python_module(self): """Test loading rez plugin from python modules""" with restore_sys_path(): sys.path.append(self.data_path("extensions")) @@ -76,7 +76,7 @@ def test_load_plugin_from_entry_points(self): "command", "baz") self.assertEqual(baz_cls.name(), "baz") - def _test_plugin_override_1(self): + def test_plugin_override_1(self): """Test plugin from plugin_path can override the default""" self.update_settings(dict( plugin_path=[self.data_path("extensions", "non-mod")] @@ -86,7 +86,7 @@ def _test_plugin_override_1(self): "package_repository", "memory") self.assertEqual("non-mod", mem_cls.on_test) - def _test_plugin_override_2(self): + def test_plugin_override_2(self): """Test plugin from python modules can override the default""" with restore_sys_path(): sys.path.append(self.data_path("extensions")) @@ -95,7 +95,7 @@ def _test_plugin_override_2(self): "package_repository", "memory") self.assertEqual("bar", mem_cls.on_test) - def _test_plugin_override_3(self): + def test_plugin_override_3(self): """Test plugin from python modules can override plugin_path""" with restore_sys_path(): # setup new diff --git a/src/rez/tests/util.py b/src/rez/tests/util.py index fca272282..3a497e65f 100644 --- a/src/rez/tests/util.py +++ b/src/rez/tests/util.py @@ -301,7 +301,6 @@ def wrapper(self, *args, **kwargs): return decorator - _restore_sys_path_lock = threading.Lock() _restore_os_environ_lock = threading.Lock() _restore_pip_lock = threading.Lock() @@ -365,13 +364,14 @@ def restore_os_environ(): os.environ.clear() os.environ.update(original) + @contextmanager def restore_pip(package_name, package_path): from pip._internal import main as pipmain - + with _restore_pip_lock: pipmain(['install', package_path]) - + yield True - pipmain(['uninstall', package_name, "-y"]) \ No newline at end of file + pipmain(['uninstall', package_name, "-y"])