From 9d9832f8e2f0202c01d847023d41b18b854cd219 Mon Sep 17 00:00:00 2001 From: Ghostkeeper Date: Wed, 22 Mar 2017 16:48:58 +0100 Subject: [PATCH] Move findSomeContainers out to global function This way we can re-use it for other tests. Contributes to issue CURA-3497. --- tests/Settings/TestGlobalStack.py | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/tests/Settings/TestGlobalStack.py b/tests/Settings/TestGlobalStack.py index ad0552db92..99877b2b16 100644 --- a/tests/Settings/TestGlobalStack.py +++ b/tests/Settings/TestGlobalStack.py @@ -22,6 +22,14 @@ def container_registry(): registry.findContainers = findContainers return registry +## Place-in function for findContainer that finds only containers that start +# with "some_". +def findSomeContainers(container_id = "*", container_type = None, type = None, category = "*"): + if container_id.startswith("some_"): + return UM.Settings.ContainerRegistry._EmptyInstanceContainer(container_id) + if container_type == DefinitionContainer: + return unittest.mock.MagicMock() + ## Tests whether the user changes are being read properly from a global stack. @pytest.mark.parametrize("filename, user_changes_id", [ ("Global.global.cfg", "empty"), @@ -36,12 +44,7 @@ def test_deserializeUserChanges(filename, user_changes_id, container_registry): stack = cura.Settings.GlobalStack.GlobalStack("TestStack") #Mock the loading of the instances. - def findContainer(container_id = "*", container_type = None, type = None, category = "*"): - if container_id.startswith("some_"): - return UM.Settings.ContainerRegistry._EmptyInstanceContainer(container_id) - if container_type == DefinitionContainer: - return unittest.mock.MagicMock() - stack.findContainer = findContainer + stack.findContainer = findSomeContainers UM.Settings.ContainerStack._containerRegistry = container_registry #Always has all profiles you ask of. stack.deserialize(serialized)