Restore the original container registry after each test

A bit of code duplication, but I don't see how to reduce this at the moment.

Contributes to issue CURA-3497.
This commit is contained in:
Ghostkeeper 2017-03-23 17:17:43 +01:00
parent b18c72bbbf
commit 9ce621a02d
No known key found for this signature in database
GPG key ID: C5F96EE2BC0F7E75

View file

@ -60,12 +60,16 @@ def test_deserializeUserChanges(filename, user_changes_id, container_registry, g
#Mock the loading of the instance containers.
global_stack.findContainer = findSomeContainers
original_container_registry = UM.Settings.ContainerStack._containerRegistry
UM.Settings.ContainerStack._containerRegistry = container_registry #Always has all profiles you ask of.
global_stack.deserialize(serialized)
assert global_stack.userChanges.getId() == user_changes_id
#Restore.
UM.Settings.ContainerStack._containerRegistry = original_container_registry
## Tests whether the quality changes are being read properly from a global
# stack.
@pytest.mark.parametrize("filename, quality_changes_id", [
@ -80,12 +84,16 @@ def test_deserializeQualityChanges(filename, quality_changes_id, container_regis
#Mock the loading of the instance containers.
global_stack.findContainer = findSomeContainers
original_container_registry = UM.Settings.ContainerStack._containerRegistry
UM.Settings.ContainerStack._containerRegistry = container_registry #Always has all the profiles you ask of.
global_stack.deserialize(serialized)
assert global_stack.qualityChanges.getId() == quality_changes_id
#Restore.
UM.Settings.ContainerStack._containerRegistry = original_container_registry
## Tests whether the quality profile is being read properly from a global
# stack.
@pytest.mark.parametrize("filename, quality_id", [
@ -100,12 +108,16 @@ def test_deserializeQuality(filename, quality_id, container_registry, global_sta
#Mock the loading of the instance containers.
global_stack.findContainer = findSomeContainers
original_container_registry = UM.Settings.ContainerStack._containerRegistry
UM.Settings.ContainerStack._containerRegistry = container_registry #Always has all the profiles you ask of.
global_stack.deserialize(serialized)
assert global_stack.quality.getId() == quality_id
#Restore.
UM.Settings.ContainerStack._containerRegistry = original_container_registry
## Tests whether the material profile is being read properly from a global
# stack.
@pytest.mark.parametrize("filename, material_id", [
@ -121,12 +133,16 @@ def test_deserializeMaterial(filename, material_id, container_registry, global_s
#Mock the loading of the instance containers.
global_stack.findContainer = findSomeContainers
original_container_registry = UM.Settings.ContainerStack._containerRegistry
UM.Settings.ContainerStack._containerRegistry = container_registry #Always has all the profiles you ask of.
global_stack.deserialize(serialized)
assert global_stack.material.getId() == material_id
#Restore.
UM.Settings.ContainerStack._containerRegistry = original_container_registry
## Tests whether the variant profile is being read properly from a global
# stack.
@pytest.mark.parametrize("filename, variant_id", [
@ -141,12 +157,16 @@ def test_deserializeVariant(filename, variant_id, container_registry, global_sta
#Mock the loading of the instance containers.
global_stack.findContainer = findSomeContainers
original_container_registry = UM.Settings.ContainerStack._containerRegistry
UM.Settings.ContainerStack._containerRegistry = container_registry #Always has all the profiles you ask of.
global_stack.deserialize(serialized)
assert global_stack.variant.getId() == variant_id
#Restore.
UM.Settings.ContainerStack._containerRegistry = original_container_registry
## Tests whether the definition changes profile is being read properly from a
# global stack.
@pytest.mark.parametrize("filename, definition_changes_id", [
@ -162,12 +182,16 @@ def test_deserializeDefinitionChanges(filename, definition_changes_id, container
#Mock the loading of the instance containers.
global_stack.findContainer = findSomeContainers
original_container_registry = UM.Settings.ContainerStack._containerRegistry
UM.Settings.ContainerStack._containerRegistry = container_registry #Always has all the profiles you ask of.
global_stack.deserialize(serialized)
assert global_stack.definitionChanges.getId() == definition_changes_id
#Restore.
UM.Settings.ContainerStack._containerRegistry = original_container_registry
## Tests whether the definition is being read properly from a global stack.
@pytest.mark.parametrize("filename, definition_id", [
("Global.global.cfg", "some_definition"),
@ -181,12 +205,16 @@ def test_deserializeDefinition(filename, definition_id, container_registry, glob
#Mock the loading of the instance containers.
global_stack.findContainer = findSomeContainers
original_container_registry = UM.Settings.ContainerStack._containerRegistry
UM.Settings.ContainerStack._containerRegistry = container_registry #Always has all the profiles you ask of.
global_stack.deserialize(serialized)
assert global_stack.definition.getId() == definition_id
#Restore.
UM.Settings.ContainerStack._containerRegistry = original_container_registry
## Tests whether the hasUserValue returns true for settings that are changed in
# the user-changes container.
def test_hasUserValueUserChanges(global_stack):