Tests: make tests pass for Anki 2.1.50 (Qt6)
* Import things from `aqt.qt` not `PyQt5`/`PyQt6` * When testing with Qt6, disable Anki's Qt5 compatibility mode * Depend on `pytest-anki` that is also Qt version agnostic
This commit is contained in:
parent
e025a44ea3
commit
901d92b067
@ -20,26 +20,20 @@ import inspect
|
||||
import json
|
||||
import os
|
||||
import os.path
|
||||
import random
|
||||
import re
|
||||
import string
|
||||
import time
|
||||
import unicodedata
|
||||
|
||||
from PyQt5 import QtCore
|
||||
from PyQt5.QtCore import QTimer
|
||||
from PyQt5.QtWidgets import QMessageBox, QCheckBox
|
||||
|
||||
import anki
|
||||
import anki.exporting
|
||||
import anki.storage
|
||||
import aqt
|
||||
from anki.cards import Card
|
||||
from anki.consts import MODEL_CLOZE
|
||||
|
||||
from anki.exporting import AnkiPackageExporter
|
||||
from anki.importing import AnkiPackageImporter
|
||||
from anki.notes import Note
|
||||
from aqt.qt import Qt, QTimer, QMessageBox, QCheckBox
|
||||
|
||||
from .edit import Edit
|
||||
|
||||
@ -391,7 +385,7 @@ class AnkiConnect:
|
||||
msg.setStandardButtons(QMessageBox.Yes|QMessageBox.No)
|
||||
msg.setDefaultButton(QMessageBox.No)
|
||||
msg.setCheckBox(QCheckBox(text='Ignore further requests from "{}"'.format(origin), parent=msg))
|
||||
msg.setWindowFlags(QtCore.Qt.WindowStaysOnTopHint)
|
||||
msg.setWindowFlags(Qt.WindowStaysOnTopHint)
|
||||
pressedButton = msg.exec_()
|
||||
|
||||
if pressedButton == QMessageBox.Yes:
|
||||
|
@ -184,7 +184,7 @@ class Edit(aqt.editcurrent.EditCurrent):
|
||||
# upon a request to open the dialog via `aqt.dialogs.open()`,
|
||||
# the manager will call either the constructor or the `reopen` method
|
||||
def __init__(self, note):
|
||||
QDialog.__init__(self, None, Qt.Window)
|
||||
QDialog.__init__(self, None, Qt.WindowType.Window)
|
||||
aqt.mw.garbage_collect_on_dialog_finish(self)
|
||||
self.form = aqt.forms.editcurrent.Ui_Dialog()
|
||||
self.form.setupUi(self)
|
||||
|
@ -6,7 +6,6 @@ from dataclasses import dataclass
|
||||
import aqt.operations.note
|
||||
import pytest
|
||||
import anki.collection
|
||||
from PyQt5 import QtTest
|
||||
from _pytest.monkeypatch import MonkeyPatch # noqa
|
||||
from pytest_anki._launch import anki_running, temporary_user # noqa
|
||||
from waitress import wasyncore
|
||||
@ -15,6 +14,11 @@ from plugin import AnkiConnect
|
||||
from plugin.edit import Edit
|
||||
from plugin.util import DEFAULT_CONFIG
|
||||
|
||||
try:
|
||||
from PyQt6 import QtTest
|
||||
except ImportError:
|
||||
from PyQt5 import QtTest
|
||||
|
||||
|
||||
ac = AnkiConnect()
|
||||
|
||||
|
10
tox.ini
10
tox.ini
@ -40,25 +40,26 @@
|
||||
# LIBGL_ALWAYS_INDIRECT=1
|
||||
# QTWEBENGINE_CHROMIUM_FLAGS="--disable-gpu"
|
||||
# QT_DEBUG_PLUGINS=1
|
||||
# ANKIDEV=true
|
||||
# ANKIDEV=1
|
||||
|
||||
[tox]
|
||||
minversion = 3.24
|
||||
skipsdist = true
|
||||
skip_install = true
|
||||
envlist = py38-anki{45,46,47,48,49},py39-anki50qt5
|
||||
envlist = py38-anki{45,46,47,48,49},py39-anki{50qt5,50qt6}
|
||||
|
||||
[testenv]
|
||||
commands =
|
||||
xvfb-run python -m pytest {posargs}
|
||||
setenv =
|
||||
HOME={envdir}/home
|
||||
anki50qt6: DISABLE_QT5_COMPAT=1
|
||||
allowlist_externals =
|
||||
xvfb-run
|
||||
deps =
|
||||
pytest==7.1.1
|
||||
pytest-forked==1.4.0
|
||||
pytest-anki @ git+https://github.com/oakkitten/pytest-anki.git@97708344
|
||||
pytest-anki @ git+https://github.com/oakkitten/pytest-anki.git@a0d27aa5
|
||||
|
||||
anki45: anki==2.1.45
|
||||
anki45: aqt==2.1.45
|
||||
@ -77,3 +78,6 @@ deps =
|
||||
|
||||
anki50qt5: anki==2.1.50
|
||||
anki50qt5: aqt[qt5]==2.1.50
|
||||
|
||||
anki50qt6: anki==2.1.50
|
||||
anki50qt6: aqt[qt6]==2.1.50
|
||||
|
Loading…
Reference in New Issue
Block a user