Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
48 changes: 35 additions & 13 deletions src/jhora/tests/test_ui.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,19 +18,41 @@
#
# You should have received a copy of the GNU Affero General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
"""Basic GUI tests for the PyJHora widgets.

This module used to start a Qt application and block waiting for user
interaction. When running in headless or CI environments such behaviour
causes the test suite to hang. The tests below create the application in
``offscreen`` mode, instantiate the widget and immediately close everything so
that the suite finishes promptly.
"""

import os
import sys
import pytest
from PyQt6.QtWidgets import QApplication

def except_hook(cls, exception, traceback):
print('exception called')
sys.__excepthook__(cls, exception, traceback)
sys.excepthook = except_hook
App = QApplication(sys.argv)
#from jhora.ui.horo_chart import ChartSimple
#chart = ChartSimple()
#chart.show()
from jhora.ui.horo_chart_tabs import ChartTabbed
chart = ChartTabbed()
chart.show()
sys.exit(App.exec())
exit()

@pytest.fixture
def qapp():
"""Create a QApplication for tests and ensure it is closed afterwards."""

os.environ.setdefault("QT_QPA_PLATFORM", "offscreen")
app = QApplication.instance() or QApplication(sys.argv)
yield app
# Close all remaining windows and quit the application
for widget in list(app.topLevelWidgets()):
widget.close()
app.quit()


def test_chart_tabbed_creation(qapp):
"""Simply instantiate ``ChartTabbed`` and show/hide it."""

from jhora.ui.horo_chart_tabs import ChartTabbed

widget = ChartTabbed()
widget.show()
qapp.processEvents()
assert widget.isVisible()
widget.close()