diff --git a/tests/PrinterOutput/TestNetworkedPrinterOutputDevice.py b/tests/PrinterOutput/TestNetworkedPrinterOutputDevice.py index 84ad7f0473..2a5cc8a2d5 100644 --- a/tests/PrinterOutput/TestNetworkedPrinterOutputDevice.py +++ b/tests/PrinterOutput/TestNetworkedPrinterOutputDevice.py @@ -1,3 +1,6 @@ +# Copyright (c) 2021 Ultimaker B.V. +# Cura is released under the terms of the LGPLv3 or higher. + import time from unittest.mock import MagicMock, patch @@ -122,8 +125,9 @@ def test_put(): def test_timeout(): with patch("UM.Qt.QtApplication.QtApplication.getInstance"): - output_device = NetworkedPrinterOutputDevice(device_id="test", address="127.0.0.1", properties={}) - output_device.setConnectionState(ConnectionState.Connected) + output_device = NetworkedPrinterOutputDevice(device_id = "test", address = "127.0.0.1", properties = {}) + with patch("cura.CuraApplication.CuraApplication.getInstance"): + output_device.setConnectionState(ConnectionState.Connected) assert output_device.connectionState == ConnectionState.Connected output_device._update() @@ -131,9 +135,8 @@ def test_timeout(): output_device._last_response_time = time.time() - 15 # But we did recently ask for a response! output_device._last_request_time = time.time() - 5 - output_device._update() + with patch("cura.CuraApplication.CuraApplication.getInstance"): + output_device._update() # The connection should now be closed, since it went into timeout. assert output_device.connectionState == ConnectionState.Closed - - diff --git a/tests/PrinterOutput/TestPrinterOutputDevice.py b/tests/PrinterOutput/TestPrinterOutputDevice.py index 7a9e4e2cc5..7913e156b0 100644 --- a/tests/PrinterOutput/TestPrinterOutputDevice.py +++ b/tests/PrinterOutput/TestPrinterOutputDevice.py @@ -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")