smoke_test.py 1.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  1. #!/usr/bin/env python
  2. import pytest
  3. from pytest_html import extras
  4. import xmlrpc.client
  5. import time
  6. import subprocess
  7. import sys
  8. import time
  9. import os
  10. @pytest.fixture
  11. def screenshot_path():
  12. """
  13. Returns the path for a folder to put screenshots into.
  14. Supposed to be in the path where pytest-html writes its report.
  15. """
  16. img_path = os.path.join(os.getcwd(), "report", "images")
  17. print(f"Images will be written to {img_path}")
  18. os.makedirs(img_path, exist_ok=True)
  19. return img_path
  20. def test_start_app(app, screenshot_path, extra, process_alive):
  21. """
  22. Starts a test app to the welcome screen and creates a screenshot.
  23. """
  24. assert app.existsAndVisible("mainWindow")
  25. assert app.existsAndVisible("mainWindow/welcomeScreen")
  26. first_title = app.getStringProperty(
  27. "mainWindow/welcomeScreen/loadProjectItem_1", "title"
  28. )
  29. app.mouseClick("mainWindow/welcomeScreen/loadProjectItem_1")
  30. app.takeScreenshot("mainWindow", os.path.join(screenshot_path, "startup.png"))
  31. assert process_alive()
  32. extra.append(extras.html('<img src="images/startup.png"/>'))
  33. # @pytest.mark.parametrize('project', ['some_project.qgz'])
  34. # def test_load_project(project):
  35. # app.mouseClick() ...
  36. # time.sleep(3)
  37. #
  38. # assert first_title == 'Test'
  39. if __name__ == "__main__":
  40. sys.exit(pytest.main([__file__]))