mirror of
https://github.com/freedomofpress/dangerzone.git
synced 2025-04-28 18:02:38 +02:00
tests: Test our own custom QApplication
By default, `pytest-qt` initializes the default QApplication class that PySide offers. Dangerzone, however, defines its own QApplication subclass. Create a `qapp_cls` fixture that will force `pytest-qt` to use this subclass. For more info, see: https://pytest-qt.readthedocs.io/en/latest/qapplication.html#testing-custom-qapplications
This commit is contained in:
parent
24ba914cc8
commit
fdc53efc35
2 changed files with 14 additions and 2 deletions
|
@ -37,8 +37,8 @@ class Application(QtWidgets.QApplication):
|
||||||
document_selected = QtCore.Signal(list)
|
document_selected = QtCore.Signal(list)
|
||||||
application_activated = QtCore.Signal()
|
application_activated = QtCore.Signal()
|
||||||
|
|
||||||
def __init__(self) -> None:
|
def __init__(self, *args: typing.Any, **kwargs: typing.Any) -> None:
|
||||||
super(Application, self).__init__()
|
super(Application, self).__init__(*args, **kwargs)
|
||||||
self.setQuitOnLastWindowClosed(False)
|
self.setQuitOnLastWindowClosed(False)
|
||||||
with open(get_resource_path("dangerzone.css"), "r") as f:
|
with open(get_resource_path("dangerzone.css"), "r") as f:
|
||||||
style = f.read()
|
style = f.read()
|
||||||
|
|
12
tests/conftest.py
Normal file
12
tests/conftest.py
Normal file
|
@ -0,0 +1,12 @@
|
||||||
|
import typing
|
||||||
|
|
||||||
|
import pytest
|
||||||
|
|
||||||
|
from dangerzone.gui import Application
|
||||||
|
|
||||||
|
|
||||||
|
# Use this fixture to make `pytest-qt` invoke our custom QApplication.
|
||||||
|
# See https://pytest-qt.readthedocs.io/en/latest/qapplication.html#testing-custom-qapplications
|
||||||
|
@pytest.fixture(scope="session")
|
||||||
|
def qapp_cls() -> typing.Type[Application]:
|
||||||
|
return Application
|
Loading…
Reference in a new issue