Invoke is a leading creative engine that uses image and video generation models to empower professionals, artists, and enthusiasts to generate and create visual media using the latest AI-driven technologies. The solution offers an industry-leading application interface, and serves as the foundation for multiple commercial products.
TypeScript ai-artartificial-intelligencegenerative-artimage-generationimg2imginpaintinglatent-diffusionlinuxmacosoutpaintingstable-diffusiontxt2imgwindows
fix(tests): stop patching shutil.rmtree globally in custom-nodes uninstall test (#9369)
Lincoln Stein679224dff280
diff --git a/tests/app/routers/test_custom_nodes.py b/tests/app/routers/test_custom_nodes.pyindex f7368d30e9..3fa86c08a5 100644--- a/tests/app/routers/test_custom_nodes.py+++ b/tests/app/routers/test_custom_nodes.py@@ -129,7 +129,10 @@ class TestUninstallPackNameValidation:for pack_name in ("..", ".", "foo/bar", "..\\outside"):with (patch("invokeai.app.api.routers.custom_nodes._get_custom_nodes_path") as mock_get_path,- patch("invokeai.app.api.routers.custom_nodes.shutil.rmtree") as mock_rmtree,+ # Patch the router's `shutil` attribute, NOT `shutil.rmtree`: patching the latter+ # mutates the global shutil module, so a gc pass that finalizes a TemporaryDirectory+ # leaked anywhere else in the suite calls the mock and fails assert_not_called().+ patch("invokeai.app.api.routers.custom_nodes.shutil") as mock_shutil,patch("invokeai.app.api.routers.custom_nodes._remove_workflows_by_ids") as mock_remove_workflows,):response = asyncio.run(uninstall_custom_node_pack(MagicMock(), pack_name))@@ -138,7 +141,7 @@ class TestUninstallPackNameValidation:assert response.success is Falseassert response.message == "Invalid node pack name."mock_get_path.assert_not_called()- mock_rmtree.assert_not_called()+ mock_shutil.rmtree.assert_not_called()mock_remove_workflows.assert_not_called()