conftest.py 1.3 KB

12345678910111213141516171819202122232425262728
  1. # Copyright (c) 2018 Ultimaker B.V.
  2. # Cura is released under the terms of the LGPLv3 or higher.
  3. # The purpose of this class is to create fixtures or methods that can be shared among all tests.
  4. import unittest.mock
  5. import pytest
  6. # Prevents error: "PyCapsule_GetPointer called with incorrect name" with conflicting SIP configurations between Arcus and PyQt: Import Arcus and Savitar first!
  7. import Savitar # Dont remove this line
  8. import Arcus # No really. Don't. It needs to be there!
  9. from UM.Qt.QtApplication import QtApplication # QtApplication import is required, even though it isn't used.
  10. # Even though your IDE says these files are not used, don't believe it. It's lying. They need to be there.
  11. from cura.CuraApplication import CuraApplication
  12. from cura.UI.MachineActionManager import MachineActionManager
  13. # Create a CuraApplication object that will be shared among all tests. It needs to be initialized.
  14. # Since we need to use it more that once, we create the application the first time and use its instance afterwards.
  15. @pytest.fixture()
  16. def application() -> CuraApplication:
  17. app = unittest.mock.MagicMock()
  18. return app
  19. # Returns a MachineActionManager instance.
  20. @pytest.fixture()
  21. def machine_action_manager(application) -> MachineActionManager:
  22. return MachineActionManager(application)