mirror of
https://github.com/Ultimaker/Cura.git
synced 2025-11-02 20:52:20 -07:00
Mock application in unit tests
This commit is contained in:
parent
49e3c23d14
commit
8582a1ba1a
1 changed files with 6 additions and 4 deletions
|
|
@ -3,19 +3,21 @@
|
||||||
|
|
||||||
# The purpose of this class is to create fixtures or methods that can be shared among all tests.
|
# The purpose of this class is to create fixtures or methods that can be shared among all tests.
|
||||||
|
|
||||||
|
import unittest.mock
|
||||||
import pytest
|
import pytest
|
||||||
|
|
||||||
from UM.Qt.QtApplication import QtApplication #QtApplication import is required, even though it isn't used.
|
from UM.Qt.QtApplication import QtApplication #QtApplication import is required, even though it isn't used.
|
||||||
from cura.CuraApplication import CuraApplication
|
from cura.CuraApplication import CuraApplication
|
||||||
from cura.MachineActionManager import MachineActionManager
|
from cura.MachineActionManager import MachineActionManager
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
# Create a CuraApplication object that will be shared among all tests. It needs to be initialized.
|
# Create a CuraApplication object that will be shared among all tests. It needs to be initialized.
|
||||||
# Since we need to use it more that once, we create the application the first time and use its instance afterwards.
|
# Since we need to use it more that once, we create the application the first time and use its instance afterwards.
|
||||||
@pytest.fixture()
|
@pytest.fixture()
|
||||||
def application() -> CuraApplication:
|
def application() -> CuraApplication:
|
||||||
application = CuraApplication.getInstance()
|
app = unittest.mock.MagicMock()
|
||||||
if application is None:
|
return app
|
||||||
application = CuraApplication()
|
|
||||||
return application
|
|
||||||
|
|
||||||
# Returns a MachineActionManager instance.
|
# Returns a MachineActionManager instance.
|
||||||
@pytest.fixture()
|
@pytest.fixture()
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue