Patch CuraApplication away while running tests for output devices

It needs CuraApplication because it wants to set metadata on the printer. But this is not relevant for the tests.

Contributes to issue CURA-8609.
This commit is contained in:
Ghostkeeper 2021-10-13 10:34:59 +02:00
parent 24cd2046f8
commit a399bacab3
No known key found for this signature in database
GPG key ID: D2A8871EE34EC59A
2 changed files with 13 additions and 8 deletions

View file

@ -1,7 +1,8 @@
from unittest.mock import MagicMock
# Copyright (c) 2021 Ultimaker B.V.
# Cura is released under the terms of the LGPLv3 or higher.
import pytest
from unittest.mock import patch
from unittest.mock import MagicMock, patch
from cura.PrinterOutput.Models.ExtruderConfigurationModel import ExtruderConfigurationModel
from cura.PrinterOutput.Models.MaterialOutputModel import MaterialOutputModel
@ -33,7 +34,8 @@ def test_getAndSet(data, printer_output_device):
setattr(model, data["attribute"] + "Changed", MagicMock())
# Attempt to set the value
getattr(model, "set" + attribute)(data["value"])
with patch("cura.CuraApplication.CuraApplication.getInstance"):
getattr(model, "set" + attribute)(data["value"])
# Check if signal fired.
signal = getattr(model, data["attribute"] + "Changed")