summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorFlorian Bruhin <me@the-compiler.org>2021-08-26 16:47:12 +0200
committerFlorian Bruhin <me@the-compiler.org>2021-08-26 16:47:12 +0200
commitac9d67cce0dbecdde14c474db855243e9746ba04 (patch)
treeb564440308dc40b8ae40209a33cb1c47c95e17c6 /tests
parentba30ac2af0860a8c92503179f6867ab0b46e3d31 (diff)
downloadqutebrowser-ac9d67cce0dbecdde14c474db855243e9746ba04.tar.gz
qutebrowser-ac9d67cce0dbecdde14c474db855243e9746ba04.zip
Automatically rewrite enums
See #5904
Diffstat (limited to 'tests')
-rw-r--r--tests/end2end/fixtures/notificationserver.py10
-rw-r--r--tests/end2end/fixtures/quteprocess.py2
-rw-r--r--tests/end2end/fixtures/test_testprocess.py2
-rw-r--r--tests/end2end/fixtures/testprocess.py4
-rw-r--r--tests/end2end/test_invocations.py4
-rw-r--r--tests/helpers/fixtures.py4
-rw-r--r--tests/helpers/stubs.py2
-rw-r--r--tests/unit/browser/test_pdfjs.py2
-rw-r--r--tests/unit/browser/webengine/test_webenginetab.py12
-rw-r--r--tests/unit/browser/webkit/network/test_networkreply.py16
-rw-r--r--tests/unit/browser/webkit/network/test_pac.py6
-rw-r--r--tests/unit/browser/webkit/test_certificateerror.py6
-rw-r--r--tests/unit/browser/webkit/test_webkitelem.py2
-rw-r--r--tests/unit/completion/test_completiondelegate.py8
-rw-r--r--tests/unit/completion/test_models.py4
-rw-r--r--tests/unit/components/test_braveadblock.py2
-rw-r--r--tests/unit/config/test_config.py2
-rw-r--r--tests/unit/config/test_configtypes.py44
-rw-r--r--tests/unit/javascript/position_caret/test_position_caret.py6
-rw-r--r--tests/unit/javascript/test_js_execution.py12
-rw-r--r--tests/unit/keyinput/key_data.py2
-rw-r--r--tests/unit/keyinput/test_basekeyparser.py86
-rw-r--r--tests/unit/keyinput/test_bindingtrie.py28
-rw-r--r--tests/unit/keyinput/test_keyutils.py314
-rw-r--r--tests/unit/keyinput/test_modeman.py8
-rw-r--r--tests/unit/keyinput/test_modeparsers.py22
-rw-r--r--tests/unit/mainwindow/statusbar/test_textbase.py8
-rw-r--r--tests/unit/mainwindow/test_messageview.py8
-rw-r--r--tests/unit/mainwindow/test_prompt.py8
-rw-r--r--tests/unit/misc/test_editor.py22
-rw-r--r--tests/unit/misc/test_guiprocess.py8
-rw-r--r--tests/unit/misc/test_ipc.py50
-rw-r--r--tests/unit/misc/test_miscwidgets.py16
-rw-r--r--tests/unit/misc/test_msgbox.py16
-rw-r--r--tests/unit/misc/test_sql.py4
-rw-r--r--tests/unit/utils/test_debug.py22
-rw-r--r--tests/unit/utils/test_error.py4
-rw-r--r--tests/unit/utils/test_qtutils.py98
-rw-r--r--tests/unit/utils/test_standarddir.py8
-rw-r--r--tests/unit/utils/test_urlutils.py16
-rw-r--r--tests/unit/utils/test_utils.py2
41 files changed, 450 insertions, 450 deletions
diff --git a/tests/end2end/fixtures/notificationserver.py b/tests/end2end/fixtures/notificationserver.py
index abadde794..d11ab616f 100644
--- a/tests/end2end/fixtures/notificationserver.py
+++ b/tests/end2end/fixtures/notificationserver.py
@@ -82,7 +82,7 @@ class TestNotificationServer(QObject):
notification.DBusNotificationAdapter.PATH,
notification.DBusNotificationAdapter.INTERFACE,
self,
- QDBusConnection.ExportAllSlots,
+ QDBusConnection.RegisterOption.ExportAllSlots,
)
return True
@@ -151,7 +151,7 @@ class TestNotificationServer(QObject):
assert channel_count == (4 if has_alpha else 3)
assert bytes_per_line >= width * channel_count
- qimage_format = QImage.Format_RGBA8888 if has_alpha else QImage.Format_RGB888
+ qimage_format = QImage.Format.Format_RGBA8888 if has_alpha else QImage.Format.Format_RGB888
img = QImage(data, width, height, bytes_per_line, qimage_format)
assert not img.isNull()
assert img.width() == width
@@ -196,7 +196,7 @@ class TestNotificationServer(QObject):
@pyqtSlot(QDBusMessage, result="uint")
def Notify(self, dbus_message: QDBusMessage) -> QDBusArgument:
assert dbus_message.signature() == 'susssasa{sv}i'
- assert dbus_message.type() == QDBusMessage.MethodCallMessage
+ assert dbus_message.type() == QDBusMessage.MessageType.MethodCallMessage
message = self._parse_notify_args(*dbus_message.arguments())
@@ -213,7 +213,7 @@ class TestNotificationServer(QObject):
def GetCapabilities(self, message: QDBusMessage) -> List[str]:
assert not message.signature()
assert not message.arguments()
- assert message.type() == QDBusMessage.MethodCallMessage
+ assert message.type() == QDBusMessage.MessageType.MethodCallMessage
capabilities = ["actions", "x-kde-origin-name"]
if self.supports_body_markup:
@@ -224,7 +224,7 @@ class TestNotificationServer(QObject):
@pyqtSlot(QDBusMessage)
def CloseNotification(self, dbus_message: QDBusMessage) -> None:
assert dbus_message.signature() == 'u'
- assert dbus_message.type() == QDBusMessage.MethodCallMessage
+ assert dbus_message.type() == QDBusMessage.MessageType.MethodCallMessage
message_id = dbus_message.arguments()[0]
self.messages[message_id].closed_via_web = True
diff --git a/tests/end2end/fixtures/quteprocess.py b/tests/end2end/fixtures/quteprocess.py
index 1552f51b4..0420548e2 100644
--- a/tests/end2end/fixtures/quteprocess.py
+++ b/tests/end2end/fixtures/quteprocess.py
@@ -853,7 +853,7 @@ class QuteProc(testprocess.Process):
# We really need the same representation that the webview uses in
# its __repr__
- url = utils.elide(qurl.toDisplayString(QUrl.EncodeUnicode), 100)
+ url = utils.elide(qurl.toDisplayString(QUrl.ComponentFormattingOption.EncodeUnicode), 100)
assert url
pattern = re.compile(
diff --git a/tests/end2end/fixtures/test_testprocess.py b/tests/end2end/fixtures/test_testprocess.py
index 0cf5e6041..1bcdb4a3c 100644
--- a/tests/end2end/fixtures/test_testprocess.py
+++ b/tests/end2end/fixtures/test_testprocess.py
@@ -53,7 +53,7 @@ class PythonProcess(testprocess.Process):
def __init__(self, request):
super().__init__(request)
- self.proc.setReadChannel(QProcess.StandardOutput)
+ self.proc.setReadChannel(QProcess.ProcessChannel.StandardOutput)
self.code = None
def _parse_line(self, line):
diff --git a/tests/end2end/fixtures/testprocess.py b/tests/end2end/fixtures/testprocess.py
index c74a1a2b8..5a623fb7c 100644
--- a/tests/end2end/fixtures/testprocess.py
+++ b/tests/end2end/fixtures/testprocess.py
@@ -151,7 +151,7 @@ class Process(QObject):
self._invalid = []
self._data = []
self.proc = QProcess()
- self.proc.setReadChannel(QProcess.StandardError)
+ self.proc.setReadChannel(QProcess.ProcessChannel.StandardError)
self.exit_expected = None # Not started at all yet
def _log(self, line):
@@ -325,7 +325,7 @@ class Process(QObject):
def is_running(self):
"""Check if the process is currently running."""
- return self.proc.state() == QProcess.Running
+ return self.proc.state() == QProcess.ProcessState.Running
def _match_data(self, value, expected):
"""Helper for wait_for to match a given value.
diff --git a/tests/end2end/test_invocations.py b/tests/end2end/test_invocations.py
index 3b8b2f1c8..c3219c701 100644
--- a/tests/end2end/test_invocations.py
+++ b/tests/end2end/test_invocations.py
@@ -262,7 +262,7 @@ def test_version(request):
# can't use quteproc_new here because it's confused by
# early process termination
proc = QProcess()
- proc.setProcessChannelMode(QProcess.SeparateChannels)
+ proc.setProcessChannelMode(QProcess.ProcessChannelMode.SeparateChannels)
proc.start(sys.executable, args)
ok = proc.waitForStarted(2000)
@@ -275,7 +275,7 @@ def test_version(request):
print(stderr)
assert ok
- assert proc.exitStatus() == QProcess.NormalExit
+ assert proc.exitStatus() == QProcess.ExitStatus.NormalExit
match = re.search(r'^qutebrowser\s+v\d+(\.\d+)', stdout, re.MULTILINE)
assert match is not None
diff --git a/tests/helpers/fixtures.py b/tests/helpers/fixtures.py
index 82159233c..cd58fb3e4 100644
--- a/tests/helpers/fixtures.py
+++ b/tests/helpers/fixtures.py
@@ -126,7 +126,7 @@ class FakeStatusBar(QWidget):
self.hbox = QHBoxLayout(self)
self.hbox.addStretch()
self.hbox.setContentsMargins(0, 0, 0, 0)
- self.setAttribute(Qt.WA_StyledBackground, True)
+ self.setAttribute(Qt.WidgetAttribute.WA_StyledBackground, True)
self.setStyleSheet('background-color: red;')
def minimumSizeHint(self):
@@ -434,7 +434,7 @@ def qnam(qapp):
"""Session-wide QNetworkAccessManager."""
from PyQt6.QtNetwork import QNetworkAccessManager
nam = QNetworkAccessManager()
- nam.setNetworkAccessible(QNetworkAccessManager.NotAccessible)
+ nam.setNetworkAccessible(QNetworkAccessManager.NetworkAccessibility.NotAccessible)
return nam
diff --git a/tests/helpers/stubs.py b/tests/helpers/stubs.py
index e4cf9bcc7..233fe848b 100644
--- a/tests/helpers/stubs.py
+++ b/tests/helpers/stubs.py
@@ -135,7 +135,7 @@ class FakeNetworkReply:
"""QNetworkReply stub which provides a Content-Disposition header."""
KNOWN_HEADERS = {
- QNetworkRequest.ContentTypeHeader: 'Content-Type',
+ QNetworkRequest.KnownHeaders.ContentTypeHeader: 'Content-Type',
}
def __init__(self, headers=None, url=None):
diff --git a/tests/unit/browser/test_pdfjs.py b/tests/unit/browser/test_pdfjs.py
index eb3317d01..611bdba3e 100644
--- a/tests/unit/browser/test_pdfjs.py
+++ b/tests/unit/browser/test_pdfjs.py
@@ -52,7 +52,7 @@ def test_generate_pdfjs_page(available, snippet, monkeypatch):
assert snippet in content
-# Note that we got double protection, once because we use QUrl.FullyEncoded and
+# Note that we got double protection, once because we use QUrl.ComponentFormattingOption.FullyEncoded and
# because we use qutebrowser.utils.javascript.to_js. Characters like " are
# already replaced by QUrl.
@pytest.mark.parametrize('filename, expected', [
diff --git a/tests/unit/browser/webengine/test_webenginetab.py b/tests/unit/browser/webengine/test_webenginetab.py
index 92705a3aa..c5712571b 100644
--- a/tests/unit/browser/webengine/test_webenginetab.py
+++ b/tests/unit/browser/webengine/test_webenginetab.py
@@ -131,17 +131,17 @@ class TestWebengineScripts:
scripts_helper.inject(scripts)
script = scripts_helper.get_script()
- assert script.injectionPoint() == QWebEngineScript.DocumentReady
+ assert script.injectionPoint() == QWebEngineScript.InjectionPoint.DocumentReady
@pytest.mark.parametrize('run_at, expected', [
# UserScript::DocumentElementCreation
- ('document-start', QWebEngineScript.DocumentCreation),
+ ('document-start', QWebEngineScript.InjectionPoint.DocumentCreation),
# UserScript::DocumentLoadFinished
- ('document-end', QWebEngineScript.DocumentReady),
+ ('document-end', QWebEngineScript.InjectionPoint.DocumentReady),
# UserScript::AfterLoad
- ('document-idle', QWebEngineScript.Deferred),
+ ('document-idle', QWebEngineScript.InjectionPoint.Deferred),
# default according to https://wiki.greasespot.net/Metadata_Block#.40run-at
- (None, QWebEngineScript.DocumentReady),
+ (None, QWebEngineScript.InjectionPoint.DocumentReady),
])
def test_greasemonkey_run_at_values(self, scripts_helper, run_at, expected):
if run_at is None:
@@ -207,7 +207,7 @@ class TestWebengineScripts:
def test_notification_permission_workaround():
"""Make sure the value for QWebEnginePage::Notifications is correct."""
try:
- notifications = QWebEnginePage.Notifications
+ notifications = QWebEnginePage.Feature.Notifications
except AttributeError:
pytest.skip("No Notifications member")
diff --git a/tests/unit/browser/webkit/network/test_networkreply.py b/tests/unit/browser/webkit/network/test_networkreply.py
index a64f45589..8e3320e9c 100644
--- a/tests/unit/browser/webkit/network/test_networkreply.py
+++ b/tests/unit/browser/webkit/network/test_networkreply.py
@@ -38,11 +38,11 @@ class TestFixedDataNetworkReply:
reply = networkreply.FixedDataNetworkReply(req, b'', 'test/foo')
assert reply.request() == req
assert reply.url() == req.url()
- assert reply.openMode() == QIODevice.ReadOnly
- assert reply.header(QNetworkRequest.ContentTypeHeader) == 'test/foo'
- http_code = reply.attribute(QNetworkRequest.HttpStatusCodeAttribute)
+ assert reply.openMode() == QIODevice.OpenModeFlag.ReadOnly
+ assert reply.header(QNetworkRequest.KnownHeaders.ContentTypeHeader) == 'test/foo'
+ http_code = reply.attribute(QNetworkRequest.Attribute.HttpStatusCodeAttribute)
http_reason = reply.attribute(
- QNetworkRequest.HttpReasonPhraseAttribute)
+ QNetworkRequest.Attribute.HttpReasonPhraseAttribute)
assert http_code == 200
assert http_reason == 'OK'
assert reply.isFinished()
@@ -76,7 +76,7 @@ class TestFixedDataNetworkReply:
def test_error_network_reply(qtbot, req):
reply = networkreply.ErrorNetworkReply(
- req, "This is an error", QNetworkReply.UnknownNetworkError)
+ req, "This is an error", QNetworkReply.NetworkError.UnknownNetworkError)
with qtbot.wait_signals([reply.error, reply.finished], order='strict'):
pass
@@ -84,12 +84,12 @@ def test_error_network_reply(qtbot, req):
reply.abort() # shouldn't do anything
assert reply.request() == req
assert reply.url() == req.url()
- assert reply.openMode() == QIODevice.ReadOnly
+ assert reply.openMode() == QIODevice.OpenModeFlag.ReadOnly
assert reply.isFinished()
assert not reply.isRunning()
assert reply.bytesAvailable() == 0
assert reply.readData(1) == b''
- assert reply.error() == QNetworkReply.UnknownNetworkError
+ assert reply.error() == QNetworkReply.NetworkError.UnknownNetworkError
assert reply.errorString() == "This is an error"
@@ -97,5 +97,5 @@ def test_redirect_network_reply():
url = QUrl('https://www.example.com/')
reply = networkreply.RedirectNetworkReply(url)
assert reply.readData(1) == b''
- assert reply.attribute(QNetworkRequest.RedirectionTargetAttribute) == url
+ assert reply.attribute(QNetworkRequest.Attribute.RedirectionTargetAttribute) == url
reply.abort() # shouldn't do anything
diff --git a/tests/unit/browser/webkit/network/test_pac.py b/tests/unit/browser/webkit/network/test_pac.py
index 8849e011c..a13cbba4e 100644
--- a/tests/unit/browser/webkit/network/test_pac.py
+++ b/tests/unit/browser/webkit/network/test_pac.py
@@ -44,11 +44,11 @@ def _pac_common_test(test_str):
res = pac.PACResolver(fun_str)
proxies = res.resolve(QNetworkProxyQuery(QUrl("https://example.com/test")))
assert len(proxies) == 3
- assert proxies[0].type() == QNetworkProxy.NoProxy
- assert proxies[1].type() == QNetworkProxy.HttpProxy
+ assert proxies[0].type() == QNetworkProxy.ProxyType.NoProxy
+ assert proxies[1].type() == QNetworkProxy.ProxyType.HttpProxy
assert proxies[1].hostName() == "127.0.0.1"
assert proxies[1].port() == 8080
- assert proxies[2].type() == QNetworkProxy.Socks5Proxy
+ assert proxies[2].type() == QNetworkProxy.ProxyType.Socks5Proxy
assert proxies[2].hostName() == "192.168.1.1"
assert proxies[2].port() == 4444
diff --git a/tests/unit/browser/webkit/test_certificateerror.py b/tests/unit/browser/webkit/test_certificateerror.py
index 0f298a030..e1165ca67 100644
--- a/tests/unit/browser/webkit/test_certificateerror.py
+++ b/tests/unit/browser/webkit/test_certificateerror.py
@@ -34,13 +34,13 @@ class FakeError:
@pytest.mark.parametrize('errors, expected', [
(
- [QSslError(QSslError.UnableToGetIssuerCertificate)],
+ [QSslError(QSslError.SslError.UnableToGetIssuerCertificate)],
['<p>The issuer certificate could not be found</p>'],
),
(
[
- QSslError(QSslError.UnableToGetIssuerCertificate),
- QSslError(QSslError.UnableToDecryptCertificateSignature),
+ QSslError(QSslError.SslError.UnableToGetIssuerCertificate),
+ QSslError(QSslError.SslError.UnableToDecryptCertificateSignature),
],
[
'<ul>',
diff --git a/tests/unit/browser/webkit/test_webkitelem.py b/tests/unit/browser/webkit/test_webkitelem.py
index 75317dec3..7dda80030 100644
--- a/tests/unit/browser/webkit/test_webkitelem.py
+++ b/tests/unit/browser/webkit/test_webkitelem.py
@@ -124,7 +124,7 @@ def get_webelem(geometry=None, frame=None, *, null=False, style=None,
def _style_property(name, strategy):
"""Helper function to act as styleProperty method."""
- if strategy != QWebElement.ComputedStyle:
+ if strategy != QWebElement.StyleResolveStrategy.ComputedStyle:
raise ValueError("styleProperty called with strategy != "
"ComputedStyle ({})!".format(strategy))
return style_dict[name]
diff --git a/tests/unit/completion/test_completiondelegate.py b/tests/unit/completion/test_completiondelegate.py
index 1db96a904..ab86e5683 100644
--- a/tests/unit/completion/test_completiondelegate.py
+++ b/tests/unit/completion/test_completiondelegate.py
@@ -51,7 +51,7 @@ from qutebrowser.completion import completiondelegate
])
def test_highlight(pat, txt, segments):
doc = QTextDocument(txt)
- highlighter = completiondelegate._Highlighter(doc, pat, Qt.red)
+ highlighter = completiondelegate._Highlighter(doc, pat, Qt.GlobalColor.red)
highlighter.setFormat = mock.Mock()
highlighter.highlightBlock(txt)
highlighter.setFormat.assert_has_calls([
@@ -65,7 +65,7 @@ def test_benchmark_highlight(benchmark):
doc = QTextDocument(txt)
def bench():
- highlighter = completiondelegate._Highlighter(doc, pat, Qt.red)
+ highlighter = completiondelegate._Highlighter(doc, pat, Qt.GlobalColor.red)
highlighter.highlightBlock(txt)
benchmark(bench)
@@ -75,7 +75,7 @@ def test_benchmark_highlight(benchmark):
def test_pattern_hypothesis(text):
"""Make sure we can't produce invalid patterns."""
doc = QTextDocument()
- completiondelegate._Highlighter(doc, text, Qt.red)
+ completiondelegate._Highlighter(doc, text, Qt.GlobalColor.red)
def test_highlighted(qtbot):
@@ -87,7 +87,7 @@ def test_highlighted(qtbot):
that is kind of hard, so we just test it in isolation here.
"""
doc = QTextDocument()
- completiondelegate._Highlighter(doc, 'Hello', Qt.red)
+ completiondelegate._Highlighter(doc, 'Hello', Qt.GlobalColor.red)
doc.setPlainText('Hello World')
# Needed so the highlighting actually works.
diff --git a/tests/unit/completion/test_models.py b/tests/unit/completion/test_models.py
index 4777f17f6..208e23c11 100644
--- a/tests/unit/completion/test_models.py
+++ b/tests/unit/completion/test_models.py
@@ -1462,7 +1462,7 @@ def test_process_completion(monkeypatch, stubs, info):
p1.cmd = 'cmd1'
p1.args = []
p1.outcome.running = False
- p1.outcome.status = QProcess.NormalExit
+ p1.outcome.status = QProcess.ExitStatus.NormalExit
p1.outcome.code = 0
p2.pid = 1002
@@ -1474,7 +1474,7 @@ def test_process_completion(monkeypatch, stubs, info):
p3.cmd = 'cmd3'
p3.args = []
p3.outcome.running = False
- p3.outcome.status = QProcess.NormalExit
+ p3.outcome.status = QProcess.ExitStatus.NormalExit
p3.outcome.code = 1
monkeypatch.setattr(guiprocess, 'all_processes', {
diff --git a/tests/unit/components/test_braveadblock.py b/tests/unit/components/test_braveadblock.py
index 0f8f78f1b..5d8786008 100644
--- a/tests/unit/components/test_braveadblock.py
+++ b/tests/unit/components/test_braveadblock.py
@@ -327,7 +327,7 @@ def test_whitelist_on_dataset(config_stub, easylist_easyprivacy):
assert not blockutils.is_whitelisted_url(url)
config_stub.val.content.blocking.whitelist = []
assert not blockutils.is_whitelisted_url(url)
- whitelist_url = url.toString(QUrl.RemovePath) + "/*"
+ whitelist_url = url.toString(QUrl.UrlFormattingOption.RemovePath) + "/*"
config_stub.val.content.blocking.whitelist = [whitelist_url]
assert blockutils.is_whitelisted_url(url)
diff --git a/tests/unit/config/test_config.py b/tests/unit/config/test_config.py
index c69e42f4d..02e67c257 100644
--- a/tests/unit/config/test_config.py
+++ b/tests/unit/config/test_config.py
@@ -758,7 +758,7 @@ class TestContainer:
@pytest.mark.parametrize('configapi, expected', [
(object(), 'rgb'),
- (None, QColor.Rgb),
+ (None, QColor.Spec.Rgb),
])
def test_getattr_option(self, container, configapi, expected):
container._configapi = configapi
diff --git a/tests/unit/config/test_configtypes.py b/tests/unit/config/test_configtypes.py
index fbffa1fb5..0cb18e3d6 100644
--- a/tests/unit/config/test_configtypes.py
+++ b/tests/unit/config/test_configtypes.py
@@ -1376,46 +1376,46 @@ class TestFont:
TESTS = {
# (style, weight, pointsize, pixelsize, family
'"Foobar Neue"':
- FontDesc(QFont.StyleNormal, QFont.Normal, -1, -1, 'Foobar Neue'),
+ FontDesc(QFont.Style.StyleNormal, QFont.Weight.Normal, -1, -1, 'Foobar Neue'),
'inconsolatazi4':
- FontDesc(QFont.StyleNormal, QFont.Normal, -1, -1,
+ FontDesc(QFont.Style.StyleNormal, QFont.Weight.Normal, -1, -1,
'inconsolatazi4'),
'Terminus (TTF)':
- FontDesc(QFont.StyleNormal, QFont.Normal, -1, -1,
+ FontDesc(QFont.Style.StyleNormal, QFont.Weight.Normal, -1, -1,
'Terminus (TTF)'),
'10pt "Foobar Neue"':
- FontDesc(QFont.StyleNormal, QFont.Normal, 10, None, 'Foobar Neue'),
+ FontDesc(QFont.Style.StyleNormal, QFont.Weight.Normal, 10, None, 'Foobar Neue'),
'10PT "Foobar Neue"':
- FontDesc(QFont.StyleNormal, QFont.Normal, 10, None, 'Foobar Neue'),
+ FontDesc(QFont.Style.StyleNormal, QFont.Weight.Normal, 10, None, 'Foobar Neue'),
'10px "Foobar Neue"':
- FontDesc(QFont.StyleNormal, QFont.Normal, None, 10, 'Foobar Neue'),
+ FontDesc(QFont.Style.StyleNormal, QFont.Weight.Normal, None, 10, 'Foobar Neue'),
'10PX "Foobar Neue"':
- FontDesc(QFont.StyleNormal, QFont.Normal, None, 10, 'Foobar Neue'),
+ FontDesc(QFont.Style.StyleNormal, QFont.Weight.Normal, None, 10, 'Foobar Neue'),
'bold "Foobar Neue"':
- FontDesc(QFont.StyleNormal, QFont.Bold, -1, -1, 'Foobar Neue'),
+ FontDesc(QFont.Style.StyleNormal, QFont.Weight.Bold, -1, -1, 'Foobar Neue'),
'italic "Foobar Neue"':
- FontDesc(QFont.StyleItalic, QFont.Normal, -1, -1, 'Foobar Neue'),
+ FontDesc(QFont.Style.StyleItalic, QFont.Weight.Normal, -1, -1, 'Foobar Neue'),
'oblique "Foobar Neue"':
- FontDesc(QFont.StyleOblique, QFont.Normal, -1, -1, 'Foobar Neue'),
+ FontDesc(QFont.Style.StyleOblique, QFont.Weight.Normal, -1, -1, 'Foobar Neue'),
'normal bold "Foobar Neue"':
- FontDesc(QFont.StyleNormal, QFont.Bold, -1, -1, 'Foobar Neue'),
+ FontDesc(QFont.Style.StyleNormal, QFont.Weight.Bold, -1, -1, 'Foobar Neue'),
'bold italic "Foobar Neue"':
- FontDesc(QFont.StyleItalic, QFont.Bold, -1, -1, 'Foobar Neue'),
+ FontDesc(QFont.Style.StyleItalic, QFont.Weight.Bold, -1, -1, 'Foobar Neue'),
'bold 10pt "Foobar Neue"':
- FontDesc(QFont.StyleNormal, QFont.Bold, 10, None, 'Foobar Neue'),
+ FontDesc(QFont.Style.StyleNormal, QFont.Weight.Bold, 10, None, 'Foobar Neue'),
'italic 10pt "Foobar Neue"':
- FontDesc(QFont.StyleItalic, QFont.Normal, 10, None, 'Foobar Neue'),
+ FontDesc(QFont.Style.StyleItalic, QFont.Weight.Normal, 10, None, 'Foobar Neue'),
'oblique 10pt "Foobar Neue"':
- FontDesc(QFont.StyleOblique, QFont.Normal, 10, None,
+ FontDesc(QFont.Style.StyleOblique, QFont.Weight.Normal, 10, None,
'Foobar Neue'),
'normal bold 10pt "Foobar Neue"':
- FontDesc(QFont.StyleNormal, QFont.Bold, 10, None, 'Foobar Neue'),
+ FontDesc(QFont.Style.StyleNormal, QFont.Weight.Bold, 10, None, 'Foobar Neue'),
'bold italic 10pt "Foobar Neue"':
- FontDesc(QFont.StyleItalic, QFont.Bold, 10, None, 'Foobar Neue'),
+ FontDesc(QFont.Style.StyleItalic, QFont.Weight.Bold, 10, None, 'Foobar Neue'),
'normal 300 10pt "Foobar Neue"':
- FontDesc(QFont.StyleNormal, 37, 10, None, 'Foobar Neue'),
+ FontDesc(QFont.Style.StyleNormal, 37, 10, None, 'Foobar Neue'),
'normal 800 10pt "Foobar Neue"':
- FontDesc(QFont.StyleNormal, 99, 10, None, 'Foobar Neue'),
+ FontDesc(QFont.Style.StyleNormal, 99, 10, None, 'Foobar Neue'),
}
font_xfail = pytest.mark.xfail(reason='FIXME: #103')
@@ -1897,11 +1897,11 @@ class TestProxy:
@pytest.mark.parametrize('val, expected', [
('system', configtypes.SYSTEM_PROXY),
- ('none', QNetworkProxy(QNetworkProxy.NoProxy)),
+ ('none', QNetworkProxy(QNetworkProxy.ProxyType.NoProxy)),
('socks://example.com/',
- QNetworkProxy(QNetworkProxy.Socks5Proxy, 'example.com')),
+ QNetworkProxy(QNetworkProxy.ProxyType.Socks5Proxy, 'example.com')),
('socks5://foo:bar@example.com:2323',
- QNetworkProxy(QNetworkProxy.Socks5Proxy, 'example.com', 2323,
+ QNetworkProxy(QNetworkProxy.ProxyType.Socks5Proxy, 'example.com', 2323,
'foo', 'bar')),
('pac+http://example.com/proxy.pac',
pac.PACFetcher(QUrl('pac+http://example.com/proxy.pac'))),
diff --git a/tests/unit/javascript/position_caret/test_position_caret.py b/tests/unit/javascript/position_caret/test_position_caret.py
index ef5ce952c..b1f9c03e1 100644
--- a/tests/unit/javascript/position_caret/test_position_caret.py
+++ b/tests/unit/javascript/position_caret/test_position_caret.py
@@ -29,10 +29,10 @@ QWebPage = pytest.importorskip("PyQt6.QtWebKitWidgets").QWebPage
def enable_caret_browsing(qapp):
"""Fixture to enable caret browsing globally."""
settings = QWebSettings.globalSettings()
- old_value = settings.testAttribute(QWebSettings.CaretBrowsingEnabled)
- settings.setAttribute(QWebSettings.CaretBrowsingEnabled, True)
+ old_value = settings.testAttribute(QWebSettings.WebAttribute.CaretBrowsingEnabled)
+ settings.setAttribute(QWebSettings.WebAttribute.CaretBrowsingEnabled, True)
yield
- settings.setAttribute(QWebSettings.CaretBrowsingEnabled, old_value)
+ settings.setAttribute(QWebSettings.WebAttribute.CaretBrowsingEnabled, old_value)
class CaretTester:
diff --git a/tests/unit/javascript/test_js_execution.py b/tests/unit/javascript/test_js_execution.py
index a98ca1175..86dda6f18 100644
--- a/tests/unit/javascript/test_js_execution.py
+++ b/tests/unit/javascript/test_js_execution.py
@@ -29,7 +29,7 @@ def test_simple_js_webkit(webview, js_enabled, expected):
# If we get there (because of the webview fixture) we can be certain
# QtWebKit is available
from PyQt6.QtWebKit import QWebSettings
- webview.settings().setAttribute(QWebSettings.JavascriptEnabled, js_enabled)
+ webview.settings().setAttribute(QWebSettings.WebAttribute.JavascriptEnabled, js_enabled)
result = webview.page().mainFrame().evaluateJavaScript('1 + 1')
assert result == expected
@@ -40,7 +40,7 @@ def test_element_js_webkit(webview, js_enabled, expected):
# If we get there (because of the webview fixture) we can be certain
# QtWebKit is available
from PyQt6.QtWebKit import QWebSettings
- webview.settings().setAttribute(QWebSettings.JavascriptEnabled, js_enabled)
+ webview.settings().setAttribute(QWebSettings.WebAttribute.JavascriptEnabled, js_enabled)
elem = webview.page().mainFrame().documentElement()
result = elem.evaluateJavaScript('1 + 1')
assert result == expected
@@ -65,12 +65,12 @@ def test_simple_js_webengine(qtbot, webengineview, qapp,
# QtWebEngine is available
from PyQt6.QtWebEngineWidgets import QWebEngineSettings, QWebEngineScript
- assert world in [QWebEngineScript.MainWorld,
- QWebEngineScript.ApplicationWorld,
- QWebEngineScript.UserWorld]
+ assert world in [QWebEngineScript.ScriptWorldId.MainWorld,
+ QWebEngineScript.ScriptWorldId.ApplicationWorld,
+ QWebEngineScript.ScriptWorldId.UserWorld]
settings = webengineview.settings()
- settings.setAttribute(QWebEngineSettings.JavascriptEnabled, js_enabled)
+ settings.setAttribute(QWebEngineSettings.WebAttribute.JavascriptEnabled, js_enabled)
qapp.processEvents()
page = webengineview.page()
diff --git a/tests/unit/keyinput/key_data.py b/tests/unit/keyinput/key_data.py
index ffa375d16..cb751ba9c 100644
--- a/tests/unit/keyinput/key_data.py
+++ b/tests/unit/keyinput/key_data.py
@@ -62,7 +62,7 @@ class Modifier:
Attributes:
attribute: The name of the Qt::KeyboardModifier attribute
- ('Shift' -> Qt.ShiftModifier)
+ ('Shift' -> Qt.KeyboardModifier.ShiftModifier)
name: The name returned by str(KeyInfo) with that modifier.
member: The numeric value.
"""
diff --git a/tests/unit/keyinput/test_basekeyparser.py b/tests/unit/keyinput/test_basekeyparser.py
index a857d451b..3e8216f24 100644
--- a/tests/unit/keyinput/test_basekeyparser.py
+++ b/tests/unit/keyinput/test_basekeyparser.py
@@ -54,7 +54,7 @@ def handle_text():
"""Helper function to handle multiple fake keypresses."""
def func(kp, *args):
for key in args:
- info = keyutils.KeyInfo(key, Qt.NoModifier)
+ info = keyutils.KeyInfo(key, Qt.KeyboardModifier.NoModifier)
kp.handle(info.to_event())
return func
@@ -119,11 +119,11 @@ def test_read_config(keyparser, key_config_stub, changed_mode, expected):
class TestHandle:
def test_valid_key(self, prompt_keyparser, handle_text):
- modifier = Qt.MetaModifier if utils.is_mac else Qt.ControlModifier
+ modifier = Qt.KeyboardModifier.MetaModifier if utils.is_mac else Qt.KeyboardModifier.ControlModifier
infos = [
- keyutils.KeyInfo(Qt.Key_A, modifier),
- keyutils.KeyInfo(Qt.Key_X, modifier),
+ keyutils.KeyInfo(Qt.Key.Key_A, modifier),
+ keyutils.KeyInfo(Qt.Key.Key_X, modifier),
]
for info in infos:
prompt_keyparser.handle(info.to_event())
@@ -133,11 +133,11 @@ class TestHandle:
assert not prompt_keyparser._sequence
def test_valid_key_count(self, prompt_keyparser):
- modifier = Qt.MetaModifier if utils.is_mac else Qt.ControlModifier
+ modifier = Qt.KeyboardModifier.MetaModifier if utils.is_mac else Qt.KeyboardModifier.ControlModifier
infos = [
- keyutils.KeyInfo(Qt.Key_5, Qt.NoModifier),
- keyutils.KeyInfo(Qt.Key_A, modifier),
+ keyutils.KeyInfo(Qt.Key.Key_5, Qt.KeyboardModifier.NoModifier),
+ keyutils.KeyInfo(Qt.Key.Key_A, modifier),
]
for info in infos:
prompt_keyparser.handle(info.to_event())
@@ -145,10 +145,10 @@ class TestHandle:
'message-info ctrla', 5)
@pytest.mark.parametrize('keys', [
- [(Qt.Key_B, Qt.NoModifier), (Qt.Key_C, Qt.NoModifier)],
- [(Qt.Key_A, Qt.ControlModifier | Qt.AltModifier)],
+ [(Qt.Key.Key_B, Qt.KeyboardModifier.NoModifier), (Qt.Key.Key_C, Qt.KeyboardModifier.NoModifier)],
+ [(Qt.Key.Key_A, Qt.KeyboardModifier.ControlModifier | Qt.KeyboardModifier.AltModifier)],
# Only modifier
- [(Qt.Key_Shift, Qt.ShiftModifier)],
+ [(Qt.Key.Key_Shift, Qt.KeyboardModifier.ShiftModifier)],
])
def test_invalid_keys(self, prompt_keyparser, keys):
for key, modifiers in keys:
@@ -158,40 +158,40 @@ class TestHandle:
assert not prompt_keyparser._sequence
def test_dry_run(self, prompt_keyparser):
- b_info = keyutils.KeyInfo(Qt.Key_B, Qt.NoModifier)
+ b_info = keyutils.KeyInfo(Qt.Key.Key_B, Qt.KeyboardModifier.NoModifier)
prompt_keyparser.handle(b_info.to_event())
- a_info = keyutils.KeyInfo(Qt.Key_A, Qt.NoModifier)
+ a_info = keyutils.KeyInfo(Qt.Key.Key_A, Qt.KeyboardModifier.NoModifier)
prompt_keyparser.handle(a_info.to_event(), dry_run=True)
assert not prompt_keyparser.execute.called
assert prompt_keyparser._sequence
def test_dry_run_count(self, prompt_keyparser):
- info = keyutils.KeyInfo(Qt.Key_9, Qt.NoModifier)
+ info = keyutils.KeyInfo(Qt.Key.Key_9, Qt.KeyboardModifier.NoModifier)
prompt_keyparser.handle(info.to_event(), dry_run=True)
assert not prompt_keyparser._count
def test_invalid_key(self, prompt_keyparser):
- keys = [Qt.Key_B, 0x0]
+ keys = [Qt.Key.Key_B, 0x0]
for key in keys:
- info = keyutils.KeyInfo(key, Qt.NoModifier)
+ info = keyutils.KeyInfo(key, Qt.KeyboardModifier.NoModifier)
prompt_keyparser.handle(info.to_event())
assert not prompt_keyparser._sequence
def test_valid_keychain(self, handle_text, prompt_keyparser):
handle_text(prompt_keyparser,
# Press 'x' which is ignored because of no match
- Qt.Key_X,
+ Qt.Key.Key_X,
# Then start the real chain
- Qt.Key_B, Qt.Key_A)
+ Qt.Key.Key_B, Qt.Key.Key_A)
prompt_keyparser.execute.assert_called_with('message-info ba', None)
assert not prompt_keyparser._sequence
@pytest.mark.parametrize('key, modifiers, number', [
- (Qt.Key_0, Qt.NoModifier, 0),
- (Qt.Key_1, Qt.NoModifier, 1),
- (Qt.Key_1, Qt.KeypadModifier, 1),
+ (Qt.Key.Key_0, Qt.KeyboardModifier.NoModifier, 0),
+ (Qt.Key.Key_1, Qt.KeyboardModifier.NoModifier, 1),
+ (Qt.Key.Key_1, Qt.KeyboardModifier.KeypadModifier, 1),
])
def test_number_press(self, prompt_keyparser,
key, modifiers, number):
@@ -201,8 +201,8 @@ class TestHandle:
assert not prompt_keyparser._sequence
@pytest.mark.parametrize('modifiers, text', [
- (Qt.NoModifier, '2'),
- (Qt.KeypadModifier, 'num-2'),
+ (Qt.KeyboardModifier.NoModifier, '2'),
+ (Qt.KeyboardModifier.KeypadModifier, 'num-2'),
])
def test_number_press_keypad(self, keyparser, config_stub,
modifiers, text):
@@ -210,18 +210,18 @@ class TestHandle:
config_stub.val.bindings.commands = {'normal': {
'2': 'message-info 2',
'<Num+2>': 'message-info num-2'}}
- keyparser.handle(keyutils.KeyInfo(Qt.Key_2, modifiers).to_event())
+ keyparser.handle(keyutils.KeyInfo(Qt.Key.Key_2, modifiers).to_event())
command = 'message-info {}'.format(text)
keyparser.execute.assert_called_once_with(command, None)
assert not keyparser._sequence
def test_umlauts(self, handle_text, keyparser, config_stub):
config_stub.val.bindings.commands = {'normal': {'ü': 'message-info ü'}}
- handle_text(keyparser, Qt.Key_Udiaeresis)
+ handle_text(keyparser, Qt.Key.Key_Udiaeresis)
keyparser.execute.assert_called_once_with('message-info ü', None)
def test_mapping(self, config_stub, handle_text, prompt_keyparser):
- handle_text(prompt_keyparser, Qt.Key_X)
+ handle_text(prompt_keyparser, Qt.Key.Key_X)
prompt_keyparser.execute.assert_called_once_with(
'message-info a', None)
@@ -230,27 +230,27 @@ class TestHandle:
config_stub.val.bindings.commands = {'normal': {'a': 'nop'}}
config_stub.val.bindings.key_mappings = {'1': 'a'}
- info = keyutils.KeyInfo(Qt.Key_1, Qt.KeypadModifier)
+ info = keyutils.KeyInfo(Qt.Key.Key_1, Qt.KeyboardModifier.KeypadModifier)
keyparser.handle(info.to_event())
keyparser.execute.assert_called_once_with('nop', None)
def test_binding_and_mapping(self, config_stub, handle_text, prompt_keyparser):
"""with a conflicting binding/mapping, the binding should win."""
- handle_text(prompt_keyparser, Qt.Key_B)
+ handle_text(prompt_keyparser, Qt.Key.Key_B)
assert not prompt_keyparser.execute.called
def test_mapping_in_key_chain(self, config_stub, handle_text, keyparser):
"""A mapping should work even as part of a keychain."""
config_stub.val.bindings.commands = {'normal':
{'aa': 'message-info aa'}}
- handle_text(keyparser, Qt.Key_A, Qt.Key_X)
+ handle_text(keyparser, Qt.Key.Key_A, Qt.Key.Key_X)
keyparser.execute.assert_called_once_with('message-info aa', None)
def test_binding_with_shift(self, prompt_keyparser):
"""Simulate a binding which involves shift."""
- for key, modifiers in [(Qt.Key_Y, Qt.NoModifier),
- (Qt.Key_Shift, Qt.ShiftModifier),
- (Qt.Key_Y, Qt.ShiftModifier)]:
+ for key, modifiers in [(Qt.Key.Key_Y, Qt.KeyboardModifier.NoModifier),
+ (Qt.Key.Key_Shift, Qt.KeyboardModifier.ShiftModifier),
+ (Qt.Key.Key_Y, Qt.KeyboardModifier.ShiftModifier)]:
info = keyutils.KeyInfo(key, modifiers)
prompt_keyparser.handle(info.to_event())
@@ -264,7 +264,7 @@ class TestHandle:
'a': 'message-info foo'
}
}
- info = keyutils.KeyInfo(Qt.Key_A, Qt.NoModifier)
+ info = keyutils.KeyInfo(Qt.Key.Key_A, Qt.KeyboardModifier.NoModifier)
keyparser.handle(info.to_event())
keyparser.execute.assert_called_once_with('message-info foo', None)
@@ -275,39 +275,39 @@ class TestCount:
def test_no_count(self, handle_text, prompt_keyparser):
"""Test with no count added."""
- handle_text(prompt_keyparser, Qt.Key_B, Qt.Key_A)
+ handle_text(prompt_keyparser, Qt.Key.Key_B, Qt.Key.Key_A)
prompt_keyparser.execute.assert_called_once_with(
'message-info ba', None)
assert not prompt_keyparser._sequence
def test_count_0(self, handle_text, prompt_keyparser):
- handle_text(prompt_keyparser, Qt.Key_0, Qt.Key_B, Qt.Key_A)
+ handle_text(prompt_keyparser, Qt.Key.Key_0, Qt.Key.Key_B, Qt.Key.Key_A)
calls = [mock.call('message-info 0', None),
mock.call('message-info ba', None)]
prompt_keyparser.execute.assert_has_calls(calls)
assert not prompt_keyparser._sequence
def test_count_42(self, handle_text, prompt_keyparser):
- handle_text(prompt_keyparser, Qt.Key_4, Qt.Key_2, Qt.Key_B, Qt.Key_A)
+ handle_text(prompt_keyparser, Qt.Key.Key_4, Qt.Key.Key_2, Qt.Key.Key_B, Qt.Key.Key_A)
prompt_keyparser.execute.assert_called_once_with('message-info ba', 42)
assert not prompt_keyparser._sequence
def test_count_42_invalid(self, handle_text, prompt_keyparser):
# Invalid call with ccx gets ignored
handle_text(prompt_keyparser,
- Qt.Key_4, Qt.Key_2, Qt.Key_C, Qt.Key_C, Qt.Key_X)
+ Qt.Key.Key_4, Qt.Key.Key_2, Qt.Key.Key_C, Qt.Key.Key_C, Qt.Key.Key_X)
assert not prompt_keyparser.execute.called
assert not prompt_keyparser._sequence
# Valid call with ccc gets the correct count
handle_text(prompt_keyparser,
- Qt.Key_2, Qt.Key_3, Qt.Key_C, Qt.Key_C, Qt.Key_C)
+ Qt.Key.Key_2, Qt.Key.Key_3, Qt.Key.Key_C, Qt.Key.Key_C, Qt.Key.Key_C)
prompt_keyparser.execute.assert_called_once_with(
'message-info ccc', 23)
assert not prompt_keyparser._sequence
def test_superscript(self, handle_text, prompt_keyparser):
# https://github.com/qutebrowser/qutebrowser/issues/3743
- handle_text(prompt_keyparser, Qt.Key_twosuperior, Qt.Key_B, Qt.Key_A)
+ handle_text(prompt_keyparser, Qt.Key.Key_twosuperior, Qt.Key.Key_B, Qt.Key.Key_A)
def test_count_keystring_update(self, qtbot,
handle_text, prompt_keyparser):
@@ -315,17 +315,17 @@ class TestCount:
with qtbot.wait_signals([
prompt_keyparser.keystring_updated,
prompt_keyparser.keystring_updated]) as blocker:
- handle_text(prompt_keyparser, Qt.Key_4, Qt.Key_2)
+ handle_text(prompt_keyparser, Qt.Key.Key_4, Qt.Key.Key_2)
sig1, sig2 = blocker.all_signals_and_args
assert sig1.args == ('4',)
assert sig2.args == ('42',)
def test_numpad(self, prompt_keyparser):
"""Make sure we can enter a count via numpad."""
- for key, modifiers in [(Qt.Key_4, Qt.KeypadModifier),
- (Qt.Key_2, Qt.KeypadModifier),
- (Qt.Key_B, Qt.NoModifier),
- (Qt.Key_A, Qt.NoModifier)]:
+ for key, modifiers in [(Qt.Key.Key_4, Qt.KeyboardModifier.KeypadModifier),
+ (Qt.Key.Key_2, Qt.KeyboardModifier.KeypadModifier),
+ (Qt.Key.Key_B, Qt.KeyboardModifier.NoModifier),
+ (Qt.Key.Key_A, Qt.KeyboardModifier.NoModifier)]:
info = keyutils.KeyInfo(key, modifiers)
prompt_keyparser.handle(info.to_event())
prompt_keyparser.execute.assert_called_once_with('message-info ba', 42)
diff --git a/tests/unit/keyinput/test_bindingtrie.py b/tests/unit/keyinput/test_bindingtrie.py
index 5c00fbbd3..64c47a54a 100644
--- a/tests/unit/keyinput/test_bindingtrie.py
+++ b/tests/unit/keyinput/test_bindingtrie.py
@@ -39,7 +39,7 @@ def test_matches_single(entered, configured, match_type):
configured = keyutils.KeySequence.parse(configured)
trie = basekeyparser.BindingTrie()
trie[configured] = "eeloo"
- command = "eeloo" if match_type == QKeySequence.ExactMatch else None
+ command = "eeloo" if match_type == QKeySequence.SequenceMatch.ExactMatch else None
result = basekeyparser.MatchResult(match_type=match_type,
command=command,
sequence=entered)
@@ -82,22 +82,22 @@ def test_str():
@pytest.mark.parametrize('configured, expected', [
([],
# null match
- [('a', QKeySequence.NoMatch),
- ('', QKeySequence.NoMatch)]),
+ [('a', QKeySequence.SequenceMatch.NoMatch),
+ ('', QKeySequence.SequenceMatch.NoMatch)]),
(['abcd'],
- [('abcd', QKeySequence.ExactMatch),
- ('abc', QKeySequence.PartialMatch)]),
+ [('abcd', QKeySequence.SequenceMatch.ExactMatch),
+ ('abc', QKeySequence.SequenceMatch.PartialMatch)]),
(['aa', 'ab', 'ac', 'ad'],
- [('ac', QKeySequence.ExactMatch),
- ('a', QKeySequence.PartialMatch),
- ('f', QKeySequence.NoMatch),
- ('acd', QKeySequence.NoMatch)]),
+ [('ac', QKeySequence.SequenceMatch.ExactMatch),
+ ('a', QKeySequence.SequenceMatch.PartialMatch),
+ ('f', QKeySequence.SequenceMatch.NoMatch),
+ ('acd', QKeySequence.SequenceMatch.NoMatch)]),
(['aaaaaaab', 'aaaaaaac', 'aaaaaaad'],
- [('aaaaaaab', QKeySequence.ExactMatch),
- ('z', QKeySequence.NoMatch)]),
+ [('aaaaaaab', QKeySequence.SequenceMatch.ExactMatch),
+ ('z', QKeySequence.SequenceMatch.NoMatch)]),
(string.ascii_letters,
- [('a', QKeySequence.ExactMatch),
- ('!', QKeySequence.NoMatch)]),
+ [('a', QKeySequence.SequenceMatch.ExactMatch),
+ ('!', QKeySequence.SequenceMatch.NoMatch)]),
])
def test_matches_tree(configured, expected, benchmark):
trie = basekeyparser.BindingTrie()
@@ -107,7 +107,7 @@ def test_matches_tree(configured, expected, benchmark):
def run():
for entered, match_type in expected:
sequence = keyutils.KeySequence.parse(entered)
- command = ("eeloo" if match_type == QKeySequence.ExactMatch
+ command = ("eeloo" if match_type == QKeySequence.SequenceMatch.ExactMatch
else None)
result = basekeyparser.MatchResult(match_type=match_type,
command=command,
diff --git a/tests/unit/keyinput/test_keyutils.py b/tests/unit/keyinput/test_keyutils.py
index 6bfa098fc..700544150 100644
--- a/tests/unit/keyinput/test_keyutils.py
+++ b/tests/unit/keyinput/test_keyutils.py
@@ -73,7 +73,7 @@ def test_key_data_modifiers():
mod_names = {name[:-len("Modifier")]
for name, value in sorted(vars(Qt).items())
if isinstance(value, Qt.KeyboardModifier) and
- value not in [Qt.NoModifier, Qt.KeyboardModifierMask]}
+ value not in [Qt.KeyboardModifier.NoModifier, Qt.KeyboardModifier.KeyboardModifierMask]}
mod_data_names = {mod.attribute for mod in sorted(key_data.MODIFIERS)}
diff = mod_names - mod_data_names
assert not diff
@@ -106,7 +106,7 @@ class TestKeyInfoText:
See key_data.py for inputs and expected values.
"""
- modifiers = Qt.ShiftModifier if upper else Qt.KeyboardModifiers()
+ modifiers = Qt.KeyboardModifier.ShiftModifier if upper else Qt.KeyboardModifiers()
info = keyutils.KeyInfo(qt_key.member, modifiers=modifiers)
expected = qt_key.uppertext if upper else qt_key.text
assert info.text() == expected
@@ -143,45 +143,45 @@ class TestKeyToString:
monkeypatch.delattr(keyutils.Qt, 'Key_AltGr')
# We don't want to test the key which is actually missing - we only
# want to know if the mapping still behaves properly.
- assert keyutils._key_to_string(Qt.Key_A) == 'A'
+ assert keyutils._key_to_string(Qt.Key.Key_A) == 'A'
@pytest.mark.parametrize('key, modifiers, expected', [
- (Qt.Key_A, Qt.NoModifier, 'a'),
- (Qt.Key_A, Qt.ShiftModifier, 'A'),
-
- (Qt.Key_Space, Qt.NoModifier, '<Space>'),
- (Qt.Key_Space, Qt.ShiftModifier, '<Shift+Space>'),
- (Qt.Key_Tab, Qt.ShiftModifier, '<Shift+Tab>'),
- (Qt.Key_A, Qt.ControlModifier, '<Ctrl+a>'),
- (Qt.Key_A, Qt.ControlModifier | Qt.ShiftModifier, '<Ctrl+Shift+a>'),
- (Qt.Key_A,
- Qt.ControlModifier | Qt.AltModifier | Qt.MetaModifier | Qt.ShiftModifier,
+ (Qt.Key.Key_A, Qt.KeyboardModifier.NoModifier, 'a'),
+ (Qt.Key.Key_A, Qt.KeyboardModifier.ShiftModifier, 'A'),
+
+ (Qt.Key.Key_Space, Qt.KeyboardModifier.NoModifier, '<Space>'),
+ (Qt.Key.Key_Space, Qt.KeyboardModifier.ShiftModifier, '<Shift+Space>'),
+ (Qt.Key.Key_Tab, Qt.KeyboardModifier.ShiftModifier, '<Shift+Tab>'),
+ (Qt.Key.Key_A, Qt.KeyboardModifier.ControlModifier, '<Ctrl+a>'),
+ (Qt.Key.Key_A, Qt.KeyboardModifier.ControlModifier | Qt.KeyboardModifier.ShiftModifier, '<Ctrl+Shift+a>'),
+ (Qt.Key.Key_A,
+ Qt.KeyboardModifier.ControlModifier | Qt.KeyboardModifier.AltModifier | Qt.KeyboardModifier.MetaModifier | Qt.KeyboardModifier.ShiftModifier,
'<Meta+Ctrl+Alt+Shift+a>'),
- (ord('Œ'), Qt.NoModifier, '<Œ>'),
- (ord('Œ'), Qt.ShiftModifier, '<Shift+Œ>'),
- (ord('Œ'), Qt.GroupSwitchModifier, '<AltGr+Œ>'),
- (ord('Œ'), Qt.GroupSwitchModifier | Qt.ShiftModifier, '<AltGr+Shift+Œ>'),
-
- (Qt.Key_Shift, Qt.ShiftModifier, '<Shift>'),
- (Qt.Key_Shift, Qt.ShiftModifier | Qt.ControlModifier, '<Ctrl+Shift>'),
- (Qt.Key_Alt, Qt.AltModifier, '<Alt>'),
- (Qt.Key_Shift, Qt.GroupSwitchModifier | Qt.ShiftModifier, '<AltGr+Shift>'),
- (Qt.Key_AltGr, Qt.GroupSwitchModifier, '<AltGr>'),
+ (ord('Œ'), Qt.KeyboardModifier.NoModifier, '<Œ>'),
+ (ord('Œ'), Qt.KeyboardModifier.ShiftModifier, '<Shift+Œ>'),
+ (ord('Œ'), Qt.KeyboardModifier.GroupSwitchModifier, '<AltGr+Œ>'),
+ (ord('Œ'), Qt.KeyboardModifier.GroupSwitchModifier | Qt.KeyboardModifier.ShiftModifier, '<AltGr+Shift+Œ>'),
+
+ (Qt.Key.Key_Shift, Qt.KeyboardModifier.ShiftModifier, '<Shift>'),
+ (Qt.Key.Key_Shift, Qt.KeyboardModifier.ShiftModifier | Qt.KeyboardModifier.ControlModifier, '<Ctrl+Shift>'),
+ (Qt.Key.Key_Alt, Qt.KeyboardModifier.AltModifier, '<Alt>'),
+ (Qt.Key.Key_Shift, Qt.KeyboardModifier.GroupSwitchModifier | Qt.KeyboardModifier.ShiftModifier, '<AltGr+Shift>'),
+ (Qt.Key.Key_AltGr, Qt.KeyboardModifier.GroupSwitchModifier, '<AltGr>'),
])
def test_key_info_str(key, modifiers, expected):
assert str(keyutils.KeyInfo(key, modifiers)) == expected
@pytest.mark.parametrize('info1, info2, equal', [
- (keyutils.KeyInfo(Qt.Key_A, Qt.NoModifier),
- keyutils.KeyInfo(Qt.Key_A, Qt.NoModifier),
+ (keyutils.KeyInfo(Qt.Key.Key_A, Qt.KeyboardModifier.NoModifier),
+ keyutils.KeyInfo(Qt.Key.Key_A, Qt.KeyboardModifier.NoModifier),
True),
- (keyutils.KeyInfo(Qt.Key_A, Qt.NoModifier),
- keyutils.KeyInfo(Qt.Key_B, Qt.NoModifier),
+ (keyutils.KeyInfo(Qt.Key.Key_A, Qt.KeyboardModifier.NoModifier),
+ keyutils.KeyInfo(Qt.Key.Key_B, Qt.KeyboardModifier.NoModifier),
False),
- (keyutils.KeyInfo(Qt.Key_A, Qt.NoModifier),
- keyutils.KeyInfo(Qt.Key_B, Qt.ControlModifier),
+ (keyutils.KeyInfo(Qt.Key.Key_A, Qt.KeyboardModifier.NoModifier),
+ keyutils.KeyInfo(Qt.Key.Key_B, Qt.KeyboardModifier.ControlModifier),
False),
])
def test_hash(info1, info2, equal):
@@ -189,9 +189,9 @@ def test_hash(info1, info2, equal):
@pytest.mark.parametrize('key, modifiers, text, expected', [
- (0xd83c, Qt.NoModifier, '🏻', '<🏻>'),
- (0xd867, Qt.NoModifier, '𩷶', '<𩷶>'),
- (0xd867, Qt.ShiftModifier, '𩷶', '<Shift+𩷶>'),
+ (0xd83c, Qt.KeyboardModifier.NoModifier, '🏻', '<🏻>'),
+ (0xd867, Qt.KeyboardModifier.NoModifier, '𩷶', '<𩷶>'),
+ (0xd867, Qt.KeyboardModifier.ShiftModifier, '𩷶', '<Shift+𩷶>'),
])
def test_surrogates(key, modifiers, text, expected):
evt = QKeyEvent(QKeyEvent.KeyPress, key, modifiers, text)
@@ -201,7 +201,7 @@ def test_surrogates(key, modifiers, text, expected):
@pytest.mark.parametrize('keys, expected', [
([0x1f3fb], '<🏻>'),
([0x29df6], '<𩷶>'),
- ([Qt.Key_Shift, 0x29df6], '<Shift><𩷶>'),
+ ([Qt.Key.Key_Shift, 0x29df6], '<Shift><𩷶>'),
([0x1f468, 0x200d, 0x1f468, 0x200d, 0x1f466], '<👨><‍><👨><‍><👦>'),
])
def test_surrogate_sequences(keys, expected):
@@ -211,7 +211,7 @@ def test_surrogate_sequences(keys, expected):
# This shouldn't happen, but if it does we should handle it well
def test_surrogate_error():
- evt = QKeyEvent(QKeyEvent.KeyPress, 0xd83e, Qt.NoModifier, '🤞🏻')
+ evt = QKeyEvent(QKeyEvent.KeyPress, 0xd83e, Qt.KeyboardModifier.NoModifier, '🤞🏻')
with pytest.raises(keyutils.KeyParseError):
keyutils.KeyInfo.from_event(evt)
@@ -246,8 +246,8 @@ def test_parse_keystr(keystr, parts):
class TestKeySequence:
def test_init(self):
- seq = keyutils.KeySequence(Qt.Key_A, Qt.Key_B, Qt.Key_C, Qt.Key_D,
- Qt.Key_E)
+ seq = keyutils.KeySequence(Qt.Key.Key_A, Qt.Key.Key_B, Qt.Key.Key_C, Qt.Key.Key_D,
+ Qt.Key.Key_E)
assert len(seq._sequences) == 2
assert len(seq._sequences[0]) == 4
assert len(seq._sequences[1]) == 1
@@ -256,7 +256,7 @@ class TestKeySequence:
seq = keyutils.KeySequence()
assert not seq
- @pytest.mark.parametrize('key', [Qt.Key_unknown, -1, 0])
+ @pytest.mark.parametrize('key', [Qt.Key.Key_unknown, -1, 0])
def test_init_unknown(self, key):
with pytest.raises(keyutils.KeyParseError):
keyutils.KeySequence(key)
@@ -283,21 +283,21 @@ class TestKeySequence:
assert str(keyutils.KeySequence.parse(orig)) == normalized
def test_iter(self):
- seq = keyutils.KeySequence(Qt.Key_A | Qt.ControlModifier,
- Qt.Key_B | Qt.ShiftModifier,
- Qt.Key_C,
- Qt.Key_D,
- Qt.Key_E)
- expected = [keyutils.KeyInfo(Qt.Key_A, Qt.ControlModifier),
- keyutils.KeyInfo(Qt.Key_B, Qt.ShiftModifier),
- keyutils.KeyInfo(Qt.Key_C, Qt.NoModifier),
- keyutils.KeyInfo(Qt.Key_D, Qt.NoModifier),
- keyutils.KeyInfo(Qt.Key_E, Qt.NoModifier)]
+ seq = keyutils.KeySequence(Qt.Key.Key_A | Qt.KeyboardModifier.ControlModifier,
+ Qt.Key.Key_B | Qt.KeyboardModifier.ShiftModifier,
+ Qt.Key.Key_C,
+ Qt.Key.Key_D,
+ Qt.Key.Key_E)
+ expected = [keyutils.KeyInfo(Qt.Key.Key_A, Qt.KeyboardModifier.ControlModifier),
+ keyutils.KeyInfo(Qt.Key.Key_B, Qt.KeyboardModifier.ShiftModifier),
+ keyutils.KeyInfo(Qt.Key.Key_C, Qt.KeyboardModifier.NoModifier),
+ keyutils.KeyInfo(Qt.Key.Key_D, Qt.KeyboardModifier.NoModifier),
+ keyutils.KeyInfo(Qt.Key.Key_E, Qt.KeyboardModifier.NoModifier)]
assert list(seq) == expected
def test_repr(self):
- seq = keyutils.KeySequence(Qt.Key_A | Qt.ControlModifier,
- Qt.Key_B | Qt.ShiftModifier)
+ seq = keyutils.KeySequence(Qt.Key.Key_A | Qt.KeyboardModifier.ControlModifier,
+ Qt.Key.Key_B | Qt.KeyboardModifier.ShiftModifier)
assert repr(seq) == ("<qutebrowser.keyinput.keyutils.KeySequence "
"keys='<Ctrl+a>B'>")
@@ -369,7 +369,7 @@ class TestKeySequence:
def test_getitem(self):
seq = keyutils.KeySequence.parse('ab')
- expected = keyutils.KeyInfo(Qt.Key_B, Qt.NoModifier)
+ expected = keyutils.KeyInfo(Qt.Key.Key_B, Qt.KeyboardModifier.NoModifier)
assert seq[1] == expected
def test_getitem_slice(self):
@@ -382,27 +382,27 @@ class TestKeySequence:
MATCH_TESTS = [
# config: abcd
- ('abc', 'abcd', QKeySequence.PartialMatch),
- ('abcd', 'abcd', QKeySequence.ExactMatch),
- ('ax', 'abcd', QKeySequence.NoMatch),
- ('abcdef', 'abcd', QKeySequence.NoMatch),
+ ('abc', 'abcd', QKeySequence.SequenceMatch.PartialMatch),
+ ('abcd', 'abcd', QKeySequence.SequenceMatch.ExactMatch),
+ ('ax', 'abcd', QKeySequence.SequenceMatch.NoMatch),
+ ('abcdef', 'abcd', QKeySequence.SequenceMatch.NoMatch),
# config: abcd ef
- ('abc', 'abcdef', QKeySequence.PartialMatch),
- ('abcde', 'abcdef', QKeySequence.PartialMatch),
- ('abcd', 'abcdef', QKeySequence.PartialMatch),
- ('abcdx', 'abcdef', QKeySequence.NoMatch),
- ('ax', 'abcdef', QKeySequence.NoMatch),
- ('abcdefg', 'abcdef', QKeySequence.NoMatch),
- ('abcdef', 'abcdef', QKeySequence.ExactMatch),
+ ('abc', 'abcdef', QKeySequence.SequenceMatch.PartialMatch),
+ ('abcde', 'abcdef', QKeySequence.SequenceMatch.PartialMatch),
+ ('abcd', 'abcdef', QKeySequence.SequenceMatch.PartialMatch),
+ ('abcdx', 'abcdef', QKeySequence.SequenceMatch.NoMatch),
+ ('ax', 'abcdef', QKeySequence.SequenceMatch.NoMatch),
+ ('abcdefg', 'abcdef', QKeySequence.SequenceMatch.NoMatch),
+ ('abcdef', 'abcdef', QKeySequence.SequenceMatch.ExactMatch),
# other examples
- ('ab', 'a', QKeySequence.NoMatch),
+ ('ab', 'a', QKeySequence.SequenceMatch.NoMatch),
# empty strings
- ('', '', QKeySequence.ExactMatch),
- ('', 'a', QKeySequence.PartialMatch),
- ('a', '', QKeySequence.NoMatch)]
+ ('', '', QKeySequence.SequenceMatch.ExactMatch),
+ ('', 'a', QKeySequence.SequenceMatch.PartialMatch),
+ ('a', '', QKeySequence.SequenceMatch.NoMatch)]
@pytest.mark.parametrize('entered, configured, match_type', MATCH_TESTS)
def test_matches(self, entered, configured, match_type):
@@ -411,33 +411,33 @@ class TestKeySequence:
assert entered.matches(configured) == match_type
@pytest.mark.parametrize('old, key, modifiers, text, expected', [
- ('a', Qt.Key_B, Qt.NoModifier, 'b', 'ab'),
- ('a', Qt.Key_B, Qt.ShiftModifier, 'B', 'aB'),
- ('a', Qt.Key_B, Qt.AltModifier | Qt.ShiftModifier, 'B',
+ ('a', Qt.Key.Key_B, Qt.KeyboardModifier.NoModifier, 'b', 'ab'),
+ ('a', Qt.Key.Key_B, Qt.KeyboardModifier.ShiftModifier, 'B', 'aB'),
+ ('a', Qt.Key.Key_B, Qt.KeyboardModifier.AltModifier | Qt.KeyboardModifier.ShiftModifier, 'B',
'a<Alt+Shift+b>'),
# Modifier stripping with symbols
- ('', Qt.Key_Colon, Qt.NoModifier, ':', ':'),
- ('', Qt.Key_Colon, Qt.ShiftModifier, ':', ':'),
- ('', Qt.Key_Colon, Qt.AltModifier | Qt.ShiftModifier, ':',
+ ('', Qt.Key.Key_Colon, Qt.KeyboardModifier.NoModifier, ':', ':'),
+ ('', Qt.Key.Key_Colon, Qt.KeyboardModifier.ShiftModifier, ':', ':'),
+ ('', Qt.Key.Key_Colon, Qt.KeyboardModifier.AltModifier | Qt.KeyboardModifier.ShiftModifier, ':',
'<Alt+Shift+:>'),
# Swapping Control/Meta on macOS
- ('', Qt.Key_A, Qt.ControlModifier, '',
+ ('', Qt.Key.Key_A, Qt.KeyboardModifier.ControlModifier, '',
'<Meta+A>' if utils.is_mac else '<Ctrl+A>'),
- ('', Qt.Key_A, Qt.ControlModifier | Qt.ShiftModifier, '',
+ ('', Qt.Key.Key_A, Qt.KeyboardModifier.ControlModifier | Qt.KeyboardModifier.ShiftModifier, '',
'<Meta+Shift+A>' if utils.is_mac else '<Ctrl+Shift+A>'),
- ('', Qt.Key_A, Qt.MetaModifier, '',
+ ('', Qt.Key.Key_A, Qt.KeyboardModifier.MetaModifier, '',
'<Ctrl+A>' if utils.is_mac else '<Meta+A>'),
# Handling of Backtab
- ('', Qt.Key_Backtab, Qt.NoModifier, '', '<Backtab>'),
- ('', Qt.Key_Backtab, Qt.ShiftModifier, '', '<Shift+Tab>'),
- ('', Qt.Key_Backtab, Qt.AltModifier | Qt.ShiftModifier, '',
+ ('', Qt.Key.Key_Backtab, Qt.KeyboardModifier.NoModifier, '', '<Backtab>'),
+ ('', Qt.Key.Key_Backtab, Qt.KeyboardModifier.ShiftModifier, '', '<Shift+Tab>'),
+ ('', Qt.Key.Key_Backtab, Qt.KeyboardModifier.AltModifier | Qt.KeyboardModifier.ShiftModifier, '',
'<Alt+Shift+Tab>'),
- # Stripping of Qt.GroupSwitchModifier
- ('', Qt.Key_A, Qt.GroupSwitchModifier, 'a', 'a'),
+ # Stripping of Qt.KeyboardModifier.GroupSwitchModifier
+ ('', Qt.Key.Key_A, Qt.KeyboardModifier.GroupSwitchModifier, 'a', 'a'),
])
def test_append_event(self, old, key, modifiers, text, expected):
seq = keyutils.KeySequence.parse(old)
@@ -447,39 +447,39 @@ class TestKeySequence:
@pytest.mark.fake_os('mac')
@pytest.mark.parametrize('modifiers, expected', [
- (Qt.ControlModifier,
- Qt.MetaModifier),
- (Qt.MetaModifier,
- Qt.ControlModifier),
- (Qt.ControlModifier | Qt.MetaModifier,
- Qt.ControlModifier | Qt.MetaModifier),
- (Qt.ControlModifier | Qt.ShiftModifier,
- Qt.MetaModifier | Qt.ShiftModifier),
- (Qt.MetaModifier | Qt.ShiftModifier,
- Qt.ControlModifier | Qt.ShiftModifier),
- (Qt.ShiftModifier, Qt.ShiftModifier),
+ (Qt.KeyboardModifier.ControlModifier,
+ Qt.KeyboardModifier.MetaModifier),
+ (Qt.KeyboardModifier.MetaModifier,
+ Qt.KeyboardModifier.ControlModifier),
+ (Qt.KeyboardModifier.ControlModifier | Qt.KeyboardModifier.MetaModifier,
+ Qt.KeyboardModifier.ControlModifier | Qt.KeyboardModifier.MetaModifier),
+ (Qt.KeyboardModifier.ControlModifier | Qt.KeyboardModifier.ShiftModifier,
+ Qt.KeyboardModifier.MetaModifier | Qt.KeyboardModifier.ShiftModifier),
+ (Qt.KeyboardModifier.MetaModifier | Qt.KeyboardModifier.ShiftModifier,
+ Qt.KeyboardModifier.ControlModifier | Qt.KeyboardModifier.ShiftModifier),
+ (Qt.KeyboardModifier.ShiftModifier, Qt.KeyboardModifier.ShiftModifier),
])
def test_fake_mac(self, modifiers, expected):
"""Make sure Control/Meta are swapped with a simulated Mac."""
seq = keyutils.KeySequence()
- info = keyutils.KeyInfo(key=Qt.Key_A, modifiers=modifiers)
+ info = keyutils.KeyInfo(key=Qt.Key.Key_A, modifiers=modifiers)
new = seq.append_event(info.to_event())
- assert new[0] == keyutils.KeyInfo(Qt.Key_A, expected)
+ assert new[0] == keyutils.KeyInfo(Qt.Key.Key_A, expected)
- @pytest.mark.parametrize('key', [Qt.Key_unknown, 0x0])
+ @pytest.mark.parametrize('key', [Qt.Key.Key_unknown, 0x0])
def test_append_event_invalid(self, key):
seq = keyutils.KeySequence()
- event = QKeyEvent(QKeyEvent.KeyPress, key, Qt.NoModifier, '')
+ event = QKeyEvent(QKeyEvent.KeyPress, key, Qt.KeyboardModifier.NoModifier, '')
with pytest.raises(keyutils.KeyParseError):
seq.append_event(event)
def test_strip_modifiers(self):
- seq = keyutils.KeySequence(Qt.Key_0,
- Qt.Key_1 | Qt.KeypadModifier,
- Qt.Key_A | Qt.ControlModifier)
- expected = keyutils.KeySequence(Qt.Key_0,
- Qt.Key_1,
- Qt.Key_A | Qt.ControlModifier)
+ seq = keyutils.KeySequence(Qt.Key.Key_0,
+ Qt.Key.Key_1 | Qt.KeyboardModifier.KeypadModifier,
+ Qt.Key.Key_A | Qt.KeyboardModifier.ControlModifier)
+ expected = keyutils.KeySequence(Qt.Key.Key_0,
+ Qt.Key.Key_1,
+ Qt.Key.Key_A | Qt.KeyboardModifier.ControlModifier)
assert seq.strip_modifiers() == expected
@pytest.mark.parametrize('inp, mappings, expected', [
@@ -497,31 +497,31 @@ class TestKeySequence:
@pytest.mark.parametrize('keystr, expected', [
('<Ctrl-Alt-y>',
- keyutils.KeySequence(Qt.ControlModifier | Qt.AltModifier | Qt.Key_Y)),
- ('x', keyutils.KeySequence(Qt.Key_X)),
- ('X', keyutils.KeySequence(Qt.ShiftModifier | Qt.Key_X)),
- ('<Escape>', keyutils.KeySequence(Qt.Key_Escape)),
- ('xyz', keyutils.KeySequence(Qt.Key_X, Qt.Key_Y, Qt.Key_Z)),
+ keyutils.KeySequence(Qt.KeyboardModifier.ControlModifier | Qt.KeyboardModifier.AltModifier | Qt.Key.Key_Y)),
+ ('x', keyutils.KeySequence(Qt.Key.Key_X)),
+ ('X', keyutils.KeySequence(Qt.KeyboardModifier.ShiftModifier | Qt.Key.Key_X)),
+ ('<Escape>', keyutils.KeySequence(Qt.Key.Key_Escape)),
+ ('xyz', keyutils.KeySequence(Qt.Key.Key_X, Qt.Key.Key_Y, Qt.Key.Key_Z)),
('<Control-x><Meta-y>',
- keyutils.KeySequence(Qt.ControlModifier | Qt.Key_X,
- Qt.MetaModifier | Qt.Key_Y)),
-
- ('<Shift-x>', keyutils.KeySequence(Qt.ShiftModifier | Qt.Key_X)),
- ('<Alt-x>', keyutils.KeySequence(Qt.AltModifier | Qt.Key_X)),
- ('<Control-x>', keyutils.KeySequence(Qt.ControlModifier | Qt.Key_X)),
- ('<Meta-x>', keyutils.KeySequence(Qt.MetaModifier | Qt.Key_X)),
- ('<Num-x>', keyutils.KeySequence(Qt.KeypadModifier | Qt.Key_X)),
-
- ('>', keyutils.KeySequence(Qt.Key_Greater)),
- ('<', keyutils.KeySequence(Qt.Key_Less)),
- ('a>', keyutils.KeySequence(Qt.Key_A, Qt.Key_Greater)),
- ('a<', keyutils.KeySequence(Qt.Key_A, Qt.Key_Less)),
- ('>a', keyutils.KeySequence(Qt.Key_Greater, Qt.Key_A)),
- ('<a', keyutils.KeySequence(Qt.Key_Less, Qt.Key_A)),
+ keyutils.KeySequence(Qt.KeyboardModifier.ControlModifier | Qt.Key.Key_X,
+ Qt.KeyboardModifier.MetaModifier | Qt.Key.Key_Y)),
+
+ ('<Shift-x>', keyutils.KeySequence(Qt.KeyboardModifier.ShiftModifier | Qt.Key.Key_X)),
+ ('<Alt-x>', keyutils.KeySequence(Qt.KeyboardModifier.AltModifier | Qt.Key.Key_X)),
+ ('<Control-x>', keyutils.KeySequence(Qt.KeyboardModifier.ControlModifier | Qt.Key.Key_X)),
+ ('<Meta-x>', keyutils.KeySequence(Qt.KeyboardModifier.MetaModifier | Qt.Key.Key_X)),
+ ('<Num-x>', keyutils.KeySequence(Qt.KeyboardModifier.KeypadModifier | Qt.Key.Key_X)),
+
+ ('>', keyutils.KeySequence(Qt.Key.Key_Greater)),
+ ('<', keyutils.KeySequence(Qt.Key.Key_Less)),
+ ('a>', keyutils.KeySequence(Qt.Key.Key_A, Qt.Key.Key_Greater)),
+ ('a<', keyutils.KeySequence(Qt.Key.Key_A, Qt.Key.Key_Less)),
+ ('>a', keyutils.KeySequence(Qt.Key.Key_Greater, Qt.Key.Key_A)),
+ ('<a', keyutils.KeySequence(Qt.Key.Key_Less, Qt.Key.Key_A)),
('<alt+greater>',
- keyutils.KeySequence(Qt.Key_Greater | Qt.AltModifier)),
+ keyutils.KeySequence(Qt.Key.Key_Greater | Qt.KeyboardModifier.AltModifier)),
('<alt+less>',
- keyutils.KeySequence(Qt.Key_Less | Qt.AltModifier)),
+ keyutils.KeySequence(Qt.Key.Key_Less | Qt.KeyboardModifier.AltModifier)),
('<alt+<>', keyutils.KeyParseError),
('<alt+>>', keyutils.KeyParseError),
@@ -547,66 +547,66 @@ class TestKeySequence:
def test_key_info_from_event():
- ev = QKeyEvent(QEvent.KeyPress, Qt.Key_A, Qt.ShiftModifier, 'A')
+ ev = QKeyEvent(QEvent.Type.KeyPress, Qt.Key.Key_A, Qt.KeyboardModifier.ShiftModifier, 'A')
info = keyutils.KeyInfo.from_event(ev)
- assert info.key == Qt.Key_A
- assert info.modifiers == Qt.ShiftModifier
+ assert info.key == Qt.Key.Key_A
+ assert info.modifiers == Qt.KeyboardModifier.ShiftModifier
def test_key_info_to_event():
- info = keyutils.KeyInfo(Qt.Key_A, Qt.ShiftModifier)
+ info = keyutils.KeyInfo(Qt.Key.Key_A, Qt.KeyboardModifier.ShiftModifier)
ev = info.to_event()
- assert ev.key() == Qt.Key_A
- assert ev.modifiers() == Qt.ShiftModifier
+ assert ev.key() == Qt.Key.Key_A
+ assert ev.modifiers() == Qt.KeyboardModifier.ShiftModifier
assert ev.text() == 'A'
def test_key_info_to_int():
- info = keyutils.KeyInfo(Qt.Key_A, Qt.ShiftModifier)
- assert info.to_int() == Qt.Key_A | Qt.ShiftModifier
+ info = keyutils.KeyInfo(Qt.Key.Key_A, Qt.KeyboardModifier.ShiftModifier)
+ assert info.to_int() == Qt.Key.Key_A | Qt.KeyboardModifier.ShiftModifier
@pytest.mark.parametrize('key, printable', [
- (Qt.Key_Control, False),
- (Qt.Key_Escape, False),
- (Qt.Key_Tab, False),
- (Qt.Key_Backtab, False),
- (Qt.Key_Backspace, False),
- (Qt.Key_Return, False),
- (Qt.Key_Enter, False),
- (Qt.Key_Space, False),
+ (Qt.Key.Key_Control, False),
+ (Qt.Key.Key_Escape, False),
+ (Qt.Key.Key_Tab, False),
+ (Qt.Key.Key_Backtab, False),
+ (Qt.Key.Key_Backspace, False),
+ (Qt.Key.Key_Return, False),
+ (Qt.Key.Key_Enter, False),
+ (Qt.Key.Key_Space, False),
(0x0, False), # Used by Qt for unknown keys
- (Qt.Key_ydiaeresis, True),
- (Qt.Key_X, True),
+ (Qt.Key.Key_ydiaeresis, True),
+ (Qt.Key.Key_X, True),
])
def test_is_printable(key, printable):
assert keyutils._is_printable(key) == printable
- assert keyutils.is_special(key, Qt.NoModifier) != printable
+ assert keyutils.is_special(key, Qt.KeyboardModifier.NoModifier) != printable
@pytest.mark.parametrize('key, modifiers, special', [
- (Qt.Key_Escape, Qt.NoModifier, True),
- (Qt.Key_Escape, Qt.ShiftModifier, True),
- (Qt.Key_Escape, Qt.ControlModifier, True),
- (Qt.Key_X, Qt.ControlModifier, True),
- (Qt.Key_X, Qt.NoModifier, False),
- (Qt.Key_2, Qt.KeypadModifier, True),
- (Qt.Key_2, Qt.NoModifier, False),
- (Qt.Key_Shift, Qt.ShiftModifier, True),
- (Qt.Key_Control, Qt.ControlModifier, True),
- (Qt.Key_Alt, Qt.AltModifier, True),
- (Qt.Key_Meta, Qt.MetaModifier, True),
- (Qt.Key_Mode_switch, Qt.GroupSwitchModifier, True),
+ (Qt.Key.Key_Escape, Qt.KeyboardModifier.NoModifier, True),
+ (Qt.Key.Key_Escape, Qt.KeyboardModifier.ShiftModifier, True),
+ (Qt.Key.Key_Escape, Qt.KeyboardModifier.ControlModifier, True),
+ (Qt.Key.Key_X, Qt.KeyboardModifier.ControlModifier, True),
+ (Qt.Key.Key_X, Qt.KeyboardModifier.NoModifier, False),
+ (Qt.Key.Key_2, Qt.KeyboardModifier.KeypadModifier, True),
+ (Qt.Key.Key_2, Qt.KeyboardModifier.NoModifier, False),
+ (Qt.Key.Key_Shift, Qt.KeyboardModifier.ShiftModifier, True),
+ (Qt.Key.Key_Control, Qt.KeyboardModifier.ControlModifier, True),
+ (Qt.Key.Key_Alt, Qt.KeyboardModifier.AltModifier, True),
+ (Qt.Key.Key_Meta, Qt.KeyboardModifier.MetaModifier, True),
+ (Qt.Key.Key_Mode_switch, Qt.KeyboardModifier.GroupSwitchModifier, True),
])
def test_is_special(key, modifiers, special):
assert keyutils.is_special(key, modifiers) == special
@pytest.mark.parametrize('key, ismodifier', [
- (Qt.Key_Control, True),
- (Qt.Key_X, False),
- (Qt.Key_Super_L, False), # Modifier but not in _MODIFIER_MAP
+ (Qt.Key.Key_Control, True),
+ (Qt.Key.Key_X, False),
+ (Qt.Key.Key_Super_L, False), # Modifier but not in _MODIFIER_MAP
])
def test_is_modifier_key(key, ismodifier):
assert keyutils.is_modifier_key(key) == ismodifier
@@ -622,4 +622,4 @@ def test_is_modifier_key(key, ismodifier):
])
def test_non_plain(func):
with pytest.raises(AssertionError):
- func(Qt.Key_X | Qt.ControlModifier)
+ func(Qt.Key.Key_X | Qt.KeyboardModifier.ControlModifier)
diff --git a/tests/unit/keyinput/test_modeman.py b/tests/unit/keyinput/test_modeman.py
index c192601f0..8b7e7e700 100644
--- a/tests/unit/keyinput/test_modeman.py
+++ b/tests/unit/keyinput/test_modeman.py
@@ -53,11 +53,11 @@ def set_qapp(monkeypatch, qapp):
@pytest.mark.parametrize('key, modifiers, filtered', [
- (Qt.Key_A, Qt.NoModifier, True),
- (Qt.Key_Up, Qt.NoModifier, False),
+ (Qt.Key.Key_A, Qt.KeyboardModifier.NoModifier, True),
+ (Qt.Key.Key_Up, Qt.KeyboardModifier.NoModifier, False),
# https://github.com/qutebrowser/qutebrowser/issues/1207
- (Qt.Key_A, Qt.ShiftModifier, True),
- (Qt.Key_A, Qt.ShiftModifier | Qt.ControlModifier, False),
+ (Qt.Key.Key_A, Qt.KeyboardModifier.ShiftModifier, True),
+ (Qt.Key.Key_A, Qt.KeyboardModifier.ShiftModifier | Qt.KeyboardModifier.ControlModifier, False),
])
def test_non_alphanumeric(key, modifiers, filtered, modeman):
"""Make sure non-alphanumeric keys are passed through correctly."""
diff --git a/tests/unit/keyinput/test_modeparsers.py b/tests/unit/keyinput/test_modeparsers.py
index fad2b2f3d..25672706f 100644
--- a/tests/unit/keyinput/test_modeparsers.py
+++ b/tests/unit/keyinput/test_modeparsers.py
@@ -65,7 +65,7 @@ class TestsNormalKeyParser:
# Press 'b' for a partial match.
# Then we check if the timer has been set up correctly
- keyparser.handle(keyutils.KeyInfo(Qt.Key_B, Qt.NoModifier).to_event())
+ keyparser.handle(keyutils.KeyInfo(Qt.Key.Key_B, Qt.KeyboardModifier.NoModifier).to_event())
assert timer.isSingleShot()
assert timer.interval() == 100
assert timer.isActive()
@@ -129,11 +129,11 @@ class TestHintKeyParser:
assert len(seq) == 2
match = keyparser.handle(seq[0].to_event())
- assert match == QKeySequence.PartialMatch
+ assert match == QKeySequence.SequenceMatch.PartialMatch
assert hintmanager.keystr == prefix
match = keyparser.handle(seq[1].to_event())
- assert match == QKeySequence.ExactMatch
+ assert match == QKeySequence.SequenceMatch.ExactMatch
assert hintmanager.keystr == hint
def test_match_key_mappings(self, config_stub, keyparser, hintmanager):
@@ -144,11 +144,11 @@ class TestHintKeyParser:
assert len(seq) == 2
match = keyparser.handle(seq[0].to_event())
- assert match == QKeySequence.PartialMatch
+ assert match == QKeySequence.SequenceMatch.PartialMatch
assert hintmanager.keystr == 'a'
match = keyparser.handle(seq[1].to_event())
- assert match == QKeySequence.ExactMatch
+ assert match == QKeySequence.SequenceMatch.ExactMatch
assert hintmanager.keystr == 'as'
def test_command(self, keyparser, config_stub, hintmanager, commandrunner):
@@ -159,17 +159,17 @@ class TestHintKeyParser:
keyparser.update_bindings(['xabcy'])
steps = [
- (Qt.Key_X, QKeySequence.PartialMatch, 'x'),
- (Qt.Key_A, QKeySequence.PartialMatch, ''),
- (Qt.Key_B, QKeySequence.PartialMatch, ''),
- (Qt.Key_C, QKeySequence.ExactMatch, ''),
+ (Qt.Key.Key_X, QKeySequence.SequenceMatch.PartialMatch, 'x'),
+ (Qt.Key.Key_A, QKeySequence.SequenceMatch.PartialMatch, ''),
+ (Qt.Key.Key_B, QKeySequence.SequenceMatch.PartialMatch, ''),
+ (Qt.Key.Key_C, QKeySequence.SequenceMatch.ExactMatch, ''),
]
for key, expected_match, keystr in steps:
- info = keyutils.KeyInfo(key, Qt.NoModifier)
+ info = keyutils.KeyInfo(key, Qt.KeyboardModifier.NoModifier)
match = keyparser.handle(info.to_event())
assert match == expected_match
assert hintmanager.keystr == keystr
- if key != Qt.Key_C:
+ if key != Qt.Key.Key_C:
assert not commandrunner.commands
assert commandrunner.commands == [('message-info abc', None)]
diff --git a/tests/unit/mainwindow/statusbar/test_textbase.py b/tests/unit/mainwindow/statusbar/test_textbase.py
index 16126d344..c2b91b7d7 100644
--- a/tests/unit/mainwindow/statusbar/test_textbase.py
+++ b/tests/unit/mainwindow/statusbar/test_textbase.py
@@ -26,10 +26,10 @@ from qutebrowser.mainwindow.statusbar.textbase import TextBase
@pytest.mark.parametrize('elidemode, check', [
- (Qt.ElideRight, lambda s: s.endswith('…') or s.endswith('...')),
- (Qt.ElideLeft, lambda s: s.startswith('…') or s.startswith('...')),
- (Qt.ElideMiddle, lambda s: '…' in s or '...' in s),
- (Qt.ElideNone, lambda s: '…' not in s and '...' not in s),
+ (Qt.TextElideMode.ElideRight, lambda s: s.endswith('…') or s.endswith('...')),
+ (Qt.TextElideMode.ElideLeft, lambda s: s.startswith('…') or s.startswith('...')),
+ (Qt.TextElideMode.ElideMiddle, lambda s: '…' in s or '...' in s),
+ (Qt.TextElideMode.ElideNone, lambda s: '…' not in s and '...' not in s),
])
def test_elided_text(fake_statusbar, qtbot, elidemode, check):
"""Ensure that a widget too small to hold the entire label text will elide.
diff --git a/tests/unit/mainwindow/test_messageview.py b/tests/unit/mainwindow/test_messageview.py
index f9b05335e..ebc0a02ce 100644
--- a/tests/unit/mainwindow/test_messageview.py
+++ b/tests/unit/mainwindow/test_messageview.py
@@ -155,10 +155,10 @@ def test_replacing_geometry(qtbot, view):
@pytest.mark.parametrize('button, count', [
- (Qt.LeftButton, 0),
- (Qt.MiddleButton, 0),
- (Qt.RightButton, 0),
- (Qt.BackButton, 2),
+ (Qt.MouseButton.LeftButton, 0),
+ (Qt.MouseButton.MiddleButton, 0),
+ (Qt.MouseButton.RightButton, 0),
+ (Qt.MouseButton.BackButton, 2),
])
def test_click_messages(qtbot, view, button, count):
"""Messages should disappear when we click on them."""
diff --git a/tests/unit/mainwindow/test_prompt.py b/tests/unit/mainwindow/test_prompt.py
index 6922183d9..385ba9007 100644
--- a/tests/unit/mainwindow/test_prompt.py
+++ b/tests/unit/mainwindow/test_prompt.py
@@ -79,7 +79,7 @@ class TestFileCompletion:
# Deleting /f[oo/]
with qtbot.wait_signal(prompt._file_model.directoryLoaded):
for _ in range(3):
- qtbot.keyPress(prompt._lineedit, Qt.Key_Backspace)
+ qtbot.keyPress(prompt._lineedit, Qt.Key.Key_Backspace)
# For some reason, this isn't always called when using qtbot.keyPress.
prompt._set_fileview_root(prompt._lineedit.text())
@@ -92,7 +92,7 @@ class TestFileCompletion:
# Deleting /[foo]
for _ in range(3):
- qtbot.keyPress(prompt._lineedit, Qt.Key_Backspace)
+ qtbot.keyPress(prompt._lineedit, Qt.Key.Key_Backspace)
# We should now show / again, so tabbing twice gives us .. -> bar
prompt.item_focus('next')
@@ -101,8 +101,8 @@ class TestFileCompletion:
@pytest.mark.parametrize("keys, expected", [
([], ['..', 'bar', 'bat', 'foo']),
- ([Qt.Key_F], ['..', 'foo']),
- ([Qt.Key_A], ['..', 'bar', 'bat']),
+ ([Qt.Key.Key_F], ['..', 'foo']),
+ ([Qt.Key.Key_A], ['..', 'bar', 'bat']),
])
def test_filtering_path(self, qtbot, tmp_path, get_prompt, keys, expected):
testdir = tmp_path / 'test'
diff --git a/tests/unit/misc/test_editor.py b/tests/unit/misc/test_editor.py
index 8187271c0..a2971b6fb 100644
--- a/tests/unit/misc/test_editor.py
+++ b/tests/unit/misc/test_editor.py
@@ -78,7 +78,7 @@ class TestFileHandling:
filename = pathlib.Path(editor._filename)
assert filename.exists()
assert filename.name.startswith('qutebrowser-editor-')
- editor._proc._proc.finished.emit(0, QProcess.NormalExit)
+ editor._proc._proc.finished.emit(0, QProcess.ExitStatus.NormalExit)
assert not filename.exists()
@pytest.mark.parametrize('touch', [True, False])
@@ -89,7 +89,7 @@ class TestFileHandling:
path.touch()
editor.edit_file(str(path))
- editor._proc._proc.finished.emit(0, QProcess.NormalExit)
+ editor._proc._proc.finished.emit(0, QProcess.ExitStatus.NormalExit)
assert path.exists()
@@ -100,7 +100,7 @@ class TestFileHandling:
assert filename.exists()
with caplog.at_level(logging.ERROR):
- editor._proc._proc.finished.emit(1, QProcess.NormalExit)
+ editor._proc._proc.finished.emit(1, QProcess.ExitStatus.NormalExit)
assert filename.exists()
@@ -112,9 +112,9 @@ class TestFileHandling:
filename = pathlib.Path(editor._filename)
assert filename.exists()
- editor._proc.error.emit(QProcess.Crashed)
+ editor._proc.error.emit(QProcess.ProcessError.Crashed)
with caplog.at_level(logging.ERROR):
- editor._proc._proc.finished.emit(0, QProcess.CrashExit)
+ editor._proc._proc.finished.emit(0, QProcess.ExitStatus.CrashExit)
assert filename.exists()
filename.unlink()
@@ -130,7 +130,7 @@ class TestFileHandling:
pytest.skip("File was still readable")
with caplog.at_level(logging.ERROR):
- editor._proc._proc.finished.emit(0, QProcess.NormalExit)
+ editor._proc._proc.finished.emit(0, QProcess.ExitStatus.NormalExit)
assert not filename.exists()
msg = message_mock.getmsg(usertypes.MessageLevel.error)
assert msg.text.startswith("Failed to read back edited file: ")
@@ -178,7 +178,7 @@ class TestFileHandling:
fname = msg.text[len(prefix):]
with qtbot.wait_signal(editor.editing_finished):
- editor._proc._proc.finished.emit(0, QProcess.NormalExit)
+ editor._proc._proc.finished.emit(0, QProcess.ExitStatus.NormalExit)
with open(fname, 'r', encoding='utf-8') as f:
assert f.read() == 'bar'
@@ -221,7 +221,7 @@ def test_modify(qtbot, editor, initial_text, edited_text):
f.write(edited_text)
with qtbot.wait_signal(editor.file_updated) as blocker:
- editor._proc._proc.finished.emit(0, QProcess.NormalExit)
+ editor._proc._proc.finished.emit(0, QProcess.ExitStatus.NormalExit)
assert blocker.args == [edited_text]
@@ -255,7 +255,7 @@ def test_modify_watch(qtbot):
assert blocker.args == ['baz']
with qtbot.assert_not_emitted(editor.file_updated):
- editor._proc._proc.finished.emit(0, QProcess.NormalExit)
+ editor._proc._proc.finished.emit(0, QProcess.ExitStatus.NormalExit)
def test_failing_watch(qtbot, caplog, monkeypatch):
@@ -273,7 +273,7 @@ def test_failing_watch(qtbot, caplog, monkeypatch):
_update_file(editor._filename, 'bar')
with qtbot.wait_signal(editor.file_updated) as blocker:
- editor._proc._proc.finished.emit(0, QProcess.NormalExit)
+ editor._proc._proc.finished.emit(0, QProcess.ExitStatus.NormalExit)
assert blocker.args == ['bar']
message = 'Failed to watch path: {}'.format(editor._filename)
@@ -290,7 +290,7 @@ def test_failing_unwatch(qtbot, caplog, monkeypatch):
editor.edit('foo')
with caplog.at_level(logging.ERROR):
- editor._proc._proc.finished.emit(0, QProcess.NormalExit)
+ editor._proc._proc.finished.emit(0, QProcess.ExitStatus.NormalExit)
message = 'Failed to unwatch paths: [{!r}]'.format(editor._filename)
assert caplog.messages[-1] == message
diff --git a/tests/unit/misc/test_guiprocess.py b/tests/unit/misc/test_guiprocess.py
index 6f7ce8810..6ee4a8164 100644
--- a/tests/unit/misc/test_guiprocess.py
+++ b/tests/unit/misc/test_guiprocess.py
@@ -36,7 +36,7 @@ def proc(qtbot, caplog):
"""A fixture providing a GUIProcess and cleaning it up after the test."""
p = guiprocess.GUIProcess('testprocess')
yield p
- if not sip.isdeleted(p._proc) and p._proc.state() != QProcess.NotRunning:
+ if not sip.isdeleted(p._proc) and p._proc.state() != QProcess.ProcessState.NotRunning:
with caplog.at_level(logging.ERROR):
with qtbot.wait_signal(p.finished, timeout=10000,
raising=False) as blocker:
@@ -126,7 +126,7 @@ def test_start(proc, qtbot, message_mock, py_proc):
assert not message_mock.messages
assert not proc.outcome.running
- assert proc.outcome.status == QProcess.NormalExit
+ assert proc.outcome.status == QProcess.ExitStatus.NormalExit
assert proc.outcome.code == 0
assert str(proc.outcome) == 'Testprocess exited successfully.'
assert proc.outcome.state_str() == 'successful'
@@ -428,7 +428,7 @@ def test_exit_unsuccessful(qtbot, proc, message_mock, py_proc, caplog):
assert msg.text == expected
assert not proc.outcome.running
- assert proc.outcome.status == QProcess.NormalExit
+ assert proc.outcome.status == QProcess.ExitStatus.NormalExit
assert proc.outcome.code == 1
assert str(proc.outcome) == 'Testprocess exited with status 1.'
assert proc.outcome.state_str() == 'unsuccessful'
@@ -448,7 +448,7 @@ def test_exit_crash(qtbot, proc, message_mock, py_proc, caplog):
assert msg.text == "Testprocess crashed. See :process for details."
assert not proc.outcome.running
- assert proc.outcome.status == QProcess.CrashExit
+ assert proc.outcome.status == QProcess.ExitStatus.CrashExit
assert str(proc.outcome) == 'Testprocess crashed.'
assert proc.outcome.state_str() == 'crashed'
assert not proc.outcome.was_successful()
diff --git a/tests/unit/misc/test_ipc.py b/tests/unit/misc/test_ipc.py
index 1bd6e4695..445dab614 100644
--- a/tests/unit/misc/test_ipc.py
+++ b/tests/unit/misc/test_ipc.py
@@ -56,7 +56,7 @@ def ipc_server(qapp, qtbot):
server = ipc.IPCServer('qute-test')
yield server
if (server._socket is not None and
- server._socket.state() != QLocalSocket.UnconnectedState):
+ server._socket.state() != QLocalSocket.LocalSocketState.UnconnectedState):
with qtbot.wait_signal(server._socket.disconnected, raising=False):
server._socket.abort()
try:
@@ -78,7 +78,7 @@ def qlocalsocket(qapp):
socket = QLocalSocket()
yield socket
socket.disconnectFromServer()
- if socket.state() != QLocalSocket.UnconnectedState:
+ if socket.state() != QLocalSocket.LocalSocketState.UnconnectedState:
socket.waitForDisconnected(1000)
@@ -103,7 +103,7 @@ class FakeSocket(QObject):
readyRead = pyqtSignal() # noqa: N815
disconnected = pyqtSignal()
- def __init__(self, *, error=QLocalSocket.UnknownSocketError, state=None,
+ def __init__(self, *, error=QLocalSocket.LocalSocketError.UnknownSocketError, state=None,
data=None, connect_successful=True, parent=None):
super().__init__(parent)
self._error_val = error
@@ -280,9 +280,9 @@ class TestExceptions:
raise exc
def test_socket_error(self, qlocalserver):
- socket = FakeSocket(error=QLocalSocket.ConnectionRefusedError)
+ socket = FakeSocket(error=QLocalSocket.LocalSocketError.ConnectionRefusedError)
exc = ipc.SocketError("testing", socket)
- assert exc.code == QLocalSocket.ConnectionRefusedError
+ assert exc.code == QLocalSocket.LocalSocketError.ConnectionRefusedError
assert exc.message == "Error string"
assert str(exc) == "Error while testing: Error string (error 0)"
@@ -322,7 +322,7 @@ class TestListen:
@pytest.mark.windows
def test_permissions_windows(self, ipc_server):
opts = ipc_server._server.socketOptions()
- assert opts == QLocalServer.UserAccessOption
+ assert opts == QLocalServer.SocketOption.UserAccessOption
@pytest.mark.posix
def test_permissions_posix(self, ipc_server):
@@ -406,21 +406,21 @@ class TestOnError:
ipc_server._socket = QLocalSocket()
ipc_server._timer.timeout.disconnect()
ipc_server._timer.start()
- ipc_server.on_error(QLocalSocket.PeerClosedError)
+ ipc_server.on_error(QLocalSocket.LocalSocketError.PeerClosedError)
assert not ipc_server._timer.isActive()
def test_other_error(self, ipc_server, monkeypatch):
socket = QLocalSocket()
ipc_server._socket = socket
monkeypatch.setattr(socket, 'error',
- lambda: QLocalSocket.ConnectionRefusedError)
+ lambda: QLocalSocket.LocalSocketError.ConnectionRefusedError)
monkeypatch.setattr(socket, 'errorString',
lambda: "Connection refused")
socket.setErrorString("Connection refused.")
with pytest.raises(ipc.Error, match=r"Error while handling IPC "
r"connection: Connection refused \(error 0\)"):
- ipc_server.on_error(QLocalSocket.ConnectionRefusedError)
+ ipc_server.on_error(QLocalSocket.LocalSocketError.ConnectionRefusedError)
class TestHandleConnection:
@@ -444,13 +444,13 @@ class TestHandleConnection:
assert any(message.startswith(msg) for message in caplog.messages)
def test_disconnected_immediately(self, ipc_server, caplog):
- socket = FakeSocket(state=QLocalSocket.UnconnectedState)
+ socket = FakeSocket(state=QLocalSocket.LocalSocketState.UnconnectedState)
ipc_server._server = FakeServer(socket)
ipc_server.handle_connection()
assert "Socket was disconnected immediately." in caplog.messages
def test_error_immediately(self, ipc_server, caplog):
- socket = FakeSocket(error=QLocalSocket.ConnectionError)
+ socket = FakeSocket(error=QLocalSocket.LocalSocketError.ConnectionError)
ipc_server._server = FakeServer(socket)
with pytest.raises(ipc.Error, match=r"Error while handling IPC "
@@ -588,7 +588,7 @@ class TestSendToRunningInstance:
assert parsed == raw_expected
def test_socket_error(self):
- socket = FakeSocket(error=QLocalSocket.ConnectionError)
+ socket = FakeSocket(error=QLocalSocket.LocalSocketError.ConnectionError)
with pytest.raises(ipc.Error, match=r"Error while writing to running "
r"instance: Error string \(error 7\)"):
ipc.send_to_running_instance('qute-test', [], None, socket=socket)
@@ -598,7 +598,7 @@ class TestSendToRunningInstance:
ipc.send_to_running_instance('qute-test', [], None, socket=socket)
def test_socket_error_no_server(self):
- socket = FakeSocket(error=QLocalSocket.ConnectionError,
+ socket = FakeSocket(error=QLocalSocket.LocalSocketError.ConnectionError,
connect_successful=False)
with pytest.raises(ipc.Error, match=r"Error while connecting to "
r"running instance: Error string \(error 7\)"):
@@ -701,14 +701,14 @@ class TestSendOrListen:
-> success
"""
qlocalserver_mock().listen.return_value = False
- err = QAbstractSocket.AddressInUseError
+ err = QAbstractSocket.SocketError.AddressInUseError
qlocalserver_mock().serverError.return_value = err
qlocalsocket_mock().waitForConnected.side_effect = [False, True]
qlocalsocket_mock().error.side_effect = [
- QLocalSocket.ServerNotFoundError,
- QLocalSocket.UnknownSocketError,
- QLocalSocket.UnknownSocketError, # error() gets called twice
+ QLocalSocket.LocalSocketError.ServerNotFoundError,
+ QLocalSocket.LocalSocketError.UnknownSocketError,
+ QLocalSocket.LocalSocketError.UnknownSocketError, # error() gets called twice
]
ret = ipc.send_or_listen(args)
@@ -734,17 +734,17 @@ class TestSendOrListen:
-> not sent / error
"""
qlocalserver_mock().listen.return_value = False
- err = QAbstractSocket.AddressInUseError
+ err = QAbstractSocket.SocketError.AddressInUseError
qlocalserver_mock().serverError.return_value = err
# If the second connection succeeds, we will have an error later.
# If it fails, that's the "not sent" case above.
qlocalsocket_mock().waitForConnected.side_effect = [False, has_error]
qlocalsocket_mock().error.side_effect = [
- QLocalSocket.ServerNotFoundError,
- QLocalSocket.ServerNotFoundError,
- QLocalSocket.ConnectionRefusedError,
- QLocalSocket.ConnectionRefusedError, # error() gets called twice
+ QLocalSocket.LocalSocketError.ServerNotFoundError,
+ QLocalSocket.LocalSocketError.ServerNotFoundError,
+ QLocalSocket.LocalSocketError.ConnectionRefusedError,
+ QLocalSocket.LocalSocketError.ConnectionRefusedError, # error() gets called twice
]
with caplog.at_level(logging.ERROR):
@@ -766,7 +766,7 @@ class TestSendOrListen:
def test_error_while_listening(self, qlocalserver_mock, caplog, args):
"""Test an error with the first listen call."""
qlocalserver_mock().listen.return_value = False
- err = QAbstractSocket.SocketResourceError
+ err = QAbstractSocket.SocketError.SocketResourceError
qlocalserver_mock().serverError.return_value = err
with caplog.at_level(logging.ERROR):
@@ -809,7 +809,7 @@ def test_connect_inexistent(qlocalsocket):
would not work properly.
"""
qlocalsocket.connectToServer('qute-test-inexistent')
- assert qlocalsocket.error() == QLocalSocket.ServerNotFoundError
+ assert qlocalsocket.error() == QLocalSocket.LocalSocketError.ServerNotFoundError
@pytest.mark.posix
@@ -826,7 +826,7 @@ def test_socket_options_address_in_use_problem(qlocalserver, short_tmpdir):
assert ok
s2 = QLocalServer()
- s2.setSocketOptions(QLocalServer.UserAccessOption)
+ s2.setSocketOptions(QLocalServer.SocketOption.UserAccessOption)
ok = s2.listen(servername)
print(s2.errorString())
# We actually would expect ok == False here - but we want the test to fail
diff --git a/tests/unit/misc/test_miscwidgets.py b/tests/unit/misc/test_miscwidgets.py
index 7749b7367..3d79ea890 100644
--- a/tests/unit/misc/test_miscwidgets.py
+++ b/tests/unit/misc/test_miscwidgets.py
@@ -48,9 +48,9 @@ class TestCommandLineEdit:
cmd_edit.home(True)
assert cmd_edit.cursorPosition() == len(':')
- qtbot.keyClick(cmd_edit, Qt.Key_Delete)
+ qtbot.keyClick(cmd_edit, Qt.Key.Key_Delete)
assert cmd_edit.text() == ':'
- qtbot.keyClick(cmd_edit, Qt.Key_Backspace)
+ qtbot.keyClick(cmd_edit, Qt.Key.Key_Backspace)
assert cmd_edit.text() == ':'
qtbot.keyClicks(cmd_edit, 'hey again')
@@ -76,7 +76,7 @@ class TestCommandLineEdit:
assert cmd_edit.text() == ':hello'
assert cmd_edit.cursorPosition() == len(':hello')
for _ in ':hello':
- qtbot.keyClick(cmd_edit, Qt.Key_Left, modifier=Qt.ShiftModifier)
+ qtbot.keyClick(cmd_edit, Qt.Key.Key_Left, modifier=Qt.KeyboardModifier.ShiftModifier)
assert cmd_edit.cursorPosition() == len(':')
assert cmd_edit.selectionStart() == len(':')
@@ -165,10 +165,10 @@ class TestInspectorSplitter:
@pytest.mark.parametrize(
'position, orientation, inspector_idx, webview_idx', [
- (inspector.Position.left, Qt.Horizontal, 0, 1),
- (inspector.Position.right, Qt.Horizontal, 1, 0),
- (inspector.Position.top, Qt.Vertical, 0, 1),
- (inspector.Position.bottom, Qt.Vertical, 1, 0),
+ (inspector.Position.left, Qt.Orientation.Horizontal, 0, 1),
+ (inspector.Position.right, Qt.Orientation.Horizontal, 1, 0),
+ (inspector.Position.top, Qt.Orientation.Vertical, 0, 1),
+ (inspector.Position.bottom, Qt.Orientation.Vertical, 1, 0),
]
)
def test_set_inspector(self, position, orientation,
@@ -260,7 +260,7 @@ class TestInspectorSplitter:
new_window_size, exp_inspector_size,
position, splitter, fake_inspector, qtbot):
def resize(dim):
- size = (QSize(dim, 666) if splitter.orientation() == Qt.Horizontal
+ size = (QSize(dim, 666) if splitter.orientation() == Qt.Orientation.Horizontal
else QSize(666, dim))
splitter.resize(size)
if splitter.size() != size:
diff --git a/tests/unit/misc/test_msgbox.py b/tests/unit/misc/test_msgbox.py
index 78f87e4c9..c8f2588d7 100644
--- a/tests/unit/misc/test_msgbox.py
+++ b/tests/unit/misc/test_msgbox.py
@@ -38,8 +38,8 @@ def test_attributes(qtbot):
text = 'text'
parent = QWidget()
qtbot.add_widget(parent)
- icon = QMessageBox.Critical
- buttons = QMessageBox.Ok | QMessageBox.Cancel
+ icon = QMessageBox.Icon.Critical
+ buttons = QMessageBox.StandardButton.Ok | QMessageBox.StandardButton.Cancel
box = msgbox.msgbox(parent=parent, title=title, text=text, icon=icon,
buttons=buttons)
@@ -53,13 +53,13 @@ def test_attributes(qtbot):
@pytest.mark.parametrize('plain_text, expected', [
- (True, Qt.PlainText),
- (False, Qt.RichText),
- (None, Qt.AutoText),
+ (True, Qt.TextFormat.PlainText),
+ (False, Qt.TextFormat.RichText),
+ (None, Qt.TextFormat.AutoText),
])
def test_plain_text(qtbot, plain_text, expected):
box = msgbox.msgbox(parent=None, title='foo', text='foo',
- icon=QMessageBox.Information, plain_text=plain_text)
+ icon=QMessageBox.Icon.Information, plain_text=plain_text)
qtbot.add_widget(box)
assert box.textFormat() == expected
@@ -73,7 +73,7 @@ def test_finished_signal(qtbot):
signal_triggered = True
box = msgbox.msgbox(parent=None, title='foo', text='foo',
- icon=QMessageBox.Information, on_finished=on_finished)
+ icon=QMessageBox.Icon.Information, on_finished=on_finished)
qtbot.add_widget(box)
@@ -89,7 +89,7 @@ def test_information(qtbot):
if not utils.is_mac:
assert box.windowTitle() == 'foo'
assert box.text() == 'bar'
- assert box.icon() == QMessageBox.Information
+ assert box.icon() == QMessageBox.Icon.Information
def test_no_err_windows(fake_args, caplog):
diff --git a/tests/unit/misc/test_sql.py b/tests/unit/misc/test_sql.py
index 4608fd9ca..35bd603b0 100644
--- a/tests/unit/misc/test_sql.py
+++ b/tests/unit/misc/test_sql.py
@@ -95,13 +95,13 @@ class TestSqlError:
(sql.SqliteErrorCode.CONSTRAINT, sql.BugError),
])
def test_known(self, error_code, exception):
- sql_err = QSqlError("driver text", "db text", QSqlError.UnknownError,
+ sql_err = QSqlError("driver text", "db text", QSqlError.ErrorType.UnknownError,
error_code)
with pytest.raises(exception):
sql.raise_sqlite_error("Message", sql_err)
def test_logging(self, caplog):
- sql_err = QSqlError("driver text", "db text", QSqlError.UnknownError, '23')
+ sql_err = QSqlError("driver text", "db text", QSqlError.ErrorType.UnknownError, '23')
with pytest.raises(sql.BugError):
sql.raise_sqlite_error("Message", sql_err)
diff --git a/tests/unit/utils/test_debug.py b/tests/unit/utils/test_debug.py
index 6f109f71f..95baba7bb 100644
--- a/tests/unit/utils/test_debug.py
+++ b/tests/unit/utils/test_debug.py
@@ -40,7 +40,7 @@ class EventObject(QObject):
def test_log_events(qapp, caplog):
obj = EventObject()
- qapp.sendEvent(obj, QEvent(QEvent.User))
+ qapp.sendEvent(obj, QEvent(QEvent.Type.User))
qapp.processEvents()
assert caplog.messages == ['Event in test_debug.EventObject: User']
@@ -133,19 +133,19 @@ class TestQEnumKey:
assert hasattr(QFrame, 'staticMetaObject')
@pytest.mark.parametrize('base, value, klass, expected', [
- (QStyle, QStyle.PE_PanelButtonCommand, None, 'PE_PanelButtonCommand'),
- (QFrame, QFrame.Sunken, None, 'Sunken'),
+ (QStyle, QStyle.PrimitiveElement.PE_PanelButtonCommand, None, 'PE_PanelButtonCommand'),
+ (QFrame, QFrame.Shadow.Sunken, None, 'Sunken'),
(QFrame, 0x0030, QFrame.Shadow, 'Sunken'),
(QFrame, 0x1337, QFrame.Shadow, '0x1337'),
- (Qt, Qt.AnchorLeft, None, 'AnchorLeft'),
+ (Qt, Qt.AnchorPoint.AnchorLeft, None, 'AnchorLeft'),
])
def test_qenum_key(self, base, value, klass, expected):
key = debug.qenum_key(base, value, klass=klass)
assert key == expected
def test_add_base(self):
- key = debug.qenum_key(QFrame, QFrame.Sunken, add_base=True)
- assert key == 'QFrame.Sunken'
+ key = debug.qenum_key(QFrame, QFrame.Shadow.Sunken, add_base=True)
+ assert key == 'QFrame.Shadow.Sunken'
def test_int_noklass(self):
"""Test passing an int without explicit klass given."""
@@ -163,10 +163,10 @@ class TestQFlagsKey:
fixme = pytest.mark.xfail(reason="See issue #42", raises=AssertionError)
@pytest.mark.parametrize('base, value, klass, expected', [
- (Qt, Qt.AlignTop, None, 'AlignTop'),
- pytest.param(Qt, Qt.AlignLeft | Qt.AlignTop, None,
+ (Qt, Qt.AlignmentFlag.AlignTop, None, 'AlignTop'),
+ pytest.param(Qt, Qt.AlignmentFlag.AlignLeft | Qt.AlignmentFlag.AlignTop, None,
'AlignLeft|AlignTop', marks=fixme),
- (Qt, Qt.AlignCenter, None, 'AlignHCenter|AlignVCenter'),
+ (Qt, Qt.AlignmentFlag.AlignCenter, None, 'AlignHCenter|AlignVCenter'),
pytest.param(Qt, 0x0021, Qt.Alignment, 'AlignLeft|AlignTop',
marks=fixme),
(Qt, 0x1100, Qt.Alignment, '0x0100|0x1000'),
@@ -199,8 +199,8 @@ class TestQFlagsKey:
def test_add_base(self):
"""Test with add_base=True."""
- flags = debug.qflags_key(Qt, Qt.AlignTop, add_base=True)
- assert flags == 'Qt.AlignTop'
+ flags = debug.qflags_key(Qt, Qt.AlignmentFlag.AlignTop, add_base=True)
+ assert flags == 'Qt.AlignmentFlag.AlignTop'
def test_int_noklass(self):
"""Test passing an int without explicit klass given."""
diff --git a/tests/unit/utils/test_error.py b/tests/unit/utils/test_error.py
index e1b7fa2e8..a51974e51 100644
--- a/tests/unit/utils/test_error.py
+++ b/tests/unit/utils/test_error.py
@@ -82,8 +82,8 @@ def test_err_windows(qtbot, qapp, pre_text, post_text, expected, caplog):
qtbot.add_widget(w)
if not utils.is_mac:
assert w.windowTitle() == 'title'
- assert w.icon() == QMessageBox.Critical
- assert w.standardButtons() == QMessageBox.Ok
+ assert w.icon() == QMessageBox.Icon.Critical
+ assert w.standardButtons() == QMessageBox.StandardButton.Ok
assert w.text() == expected
finally:
w.close()
diff --git a/tests/unit/utils/test_qtutils.py b/tests/unit/utils/test_qtutils.py
index abf3e43b1..0b9f77ff7 100644
--- a/tests/unit/utils/test_qtutils.py
+++ b/tests/unit/utils/test_qtutils.py
@@ -208,12 +208,12 @@ def test_ensure_valid(obj, raising, exc_reason, exc_str):
@pytest.mark.parametrize('status, raising, message', [
- (QDataStream.Ok, False, None),
- (QDataStream.ReadPastEnd, True, "The data stream has read past the end of "
+ (QDataStream.Status.Ok, False, None),
+ (QDataStream.Status.ReadPastEnd, True, "The data stream has read past the end of "
"the data in the underlying device."),
- (QDataStream.ReadCorruptData, True, "The data stream has read corrupt "
+ (QDataStream.Status.ReadCorruptData, True, "The data stream has read corrupt "
"data."),
- (QDataStream.WriteFailed, True, "The data stream cannot write to the "
+ (QDataStream.Status.WriteFailed, True, "The data stream cannot write to the "
"underlying device."),
])
def test_check_qdatastream(status, raising, message):
@@ -281,12 +281,12 @@ class TestSerializeStream:
def stream_mock(self):
"""Fixture providing a QDataStream-like mock."""
m = unittest.mock.MagicMock(spec=QDataStream)
- m.status.return_value = QDataStream.Ok
+ m.status.return_value = QDataStream.Status.Ok
return m
def test_serialize_pre_error_mock(self, stream_mock):
"""Test serialize_stream with an error already set."""
- stream_mock.status.return_value = QDataStream.ReadCorruptData
+ stream_mock.status.return_value = QDataStream.Status.ReadCorruptData
with pytest.raises(OSError, match="The data stream has read corrupt "
"data."):
@@ -298,7 +298,7 @@ class TestSerializeStream:
"""Test serialize_stream with an error while serializing."""
obj = QPoint()
stream_mock.__lshift__.side_effect = lambda _other: self._set_status(
- stream_mock, QDataStream.ReadCorruptData)
+ stream_mock, QDataStream.Status.ReadCorruptData)
with pytest.raises(OSError, match="The data stream has read corrupt "
"data."):
@@ -308,7 +308,7 @@ class TestSerializeStream:
def test_deserialize_pre_error_mock(self, stream_mock):
"""Test deserialize_stream with an error already set."""
- stream_mock.status.return_value = QDataStream.ReadCorruptData
+ stream_mock.status.return_value = QDataStream.Status.ReadCorruptData
with pytest.raises(OSError, match="The data stream has read corrupt "
"data."):
@@ -320,7 +320,7 @@ class TestSerializeStream:
"""Test deserialize_stream with an error while deserializing."""
obj = QPoint()
stream_mock.__rshift__.side_effect = lambda _other: self._set_status(
- stream_mock, QDataStream.ReadCorruptData)
+ stream_mock, QDataStream.Status.ReadCorruptData)
with pytest.raises(OSError, match="The data stream has read corrupt "
"data."):
@@ -334,10 +334,10 @@ class TestSerializeStream:
dest_obj = QPoint()
data = QByteArray()
- write_stream = QDataStream(data, QIODevice.WriteOnly)
+ write_stream = QDataStream(data, QIODevice.OpenModeFlag.WriteOnly)
qtutils.serialize_stream(write_stream, src_obj)
- read_stream = QDataStream(data, QIODevice.ReadOnly)
+ read_stream = QDataStream(data, QIODevice.OpenModeFlag.ReadOnly)
qtutils.deserialize_stream(read_stream, dest_obj)
assert src_obj == dest_obj
@@ -346,7 +346,7 @@ class TestSerializeStream:
def test_serialize_readonly_stream(self):
"""Test serialize_stream with a read-only stream."""
data = QByteArray()
- stream = QDataStream(data, QIODevice.ReadOnly)
+ stream = QDataStream(data, QIODevice.OpenModeFlag.ReadOnly)
with pytest.raises(OSError, match="The data stream cannot write to "
"the underlying device."):
qtutils.serialize_stream(stream, QPoint())
@@ -356,7 +356,7 @@ class TestSerializeStream:
"""Test deserialize_stream with a write-only stream."""
data = QByteArray()
obj = QPoint()
- stream = QDataStream(data, QIODevice.WriteOnly)
+ stream = QDataStream(data, QIODevice.OpenModeFlag.WriteOnly)
with pytest.raises(OSError, match="The data stream has read past the "
"end of the data in the underlying device."):
qtutils.deserialize_stream(stream, obj)
@@ -391,7 +391,7 @@ class TestSavefileOpen:
with qtutils.savefile_open('filename'):
pass
- qsavefile_mock.open.assert_called_once_with(QIODevice.WriteOnly)
+ qsavefile_mock.open.assert_called_once_with(QIODevice.OpenModeFlag.WriteOnly)
qsavefile_mock.cancelWriting.assert_called_once_with()
def test_mock_exception(self, qsavefile_mock):
@@ -402,7 +402,7 @@ class TestSavefileOpen:
with qtutils.savefile_open('filename'):
raise SavefileTestException
- qsavefile_mock.open.assert_called_once_with(QIODevice.WriteOnly)
+ qsavefile_mock.open.assert_called_once_with(QIODevice.OpenModeFlag.WriteOnly)
qsavefile_mock.cancelWriting.assert_called_once_with()
def test_mock_commit_failed(self, qsavefile_mock):
@@ -414,7 +414,7 @@ class TestSavefileOpen:
with qtutils.savefile_open('filename'):
pass
- qsavefile_mock.open.assert_called_once_with(QIODevice.WriteOnly)
+ qsavefile_mock.open.assert_called_once_with(QIODevice.OpenModeFlag.WriteOnly)
assert not qsavefile_mock.cancelWriting.called
assert not qsavefile_mock.errorString.called
@@ -429,7 +429,7 @@ class TestSavefileOpen:
with qtutils.savefile_open('filename') as f:
f.write("Hello World")
- qsavefile_mock.open.assert_called_once_with(QIODevice.WriteOnly)
+ qsavefile_mock.open.assert_called_once_with(QIODevice.OpenModeFlag.WriteOnly)
assert not qsavefile_mock.cancelWriting.called
qsavefile_mock.write.assert_called_once_with(b"Hello World")
@@ -542,10 +542,10 @@ if test_file is not None:
def open(self, _fname, mode):
"""Open an in-memory PyQIODevice instead of a real file."""
modes = {
- 'wb': QIODevice.WriteOnly | QIODevice.Truncate,
- 'w': QIODevice.WriteOnly | QIODevice.Text | QIODevice.Truncate,
- 'rb': QIODevice.ReadOnly,
- 'r': QIODevice.ReadOnly | QIODevice.Text,
+ 'wb': QIODevice.OpenModeFlag.WriteOnly | QIODevice.OpenModeFlag.Truncate,
+ 'w': QIODevice.OpenModeFlag.WriteOnly | QIODevice.OpenModeFlag.Text | QIODevice.OpenModeFlag.Truncate,
+ 'rb': QIODevice.OpenModeFlag.ReadOnly,
+ 'r': QIODevice.OpenModeFlag.ReadOnly | QIODevice.OpenModeFlag.Text,
}
try:
qt_mode = modes[mode]
@@ -658,14 +658,14 @@ class TestPyQIODevice:
Args:
method: The name of the method to call.
"""
- pyqiodev.open(QIODevice.WriteOnly)
+ pyqiodev.open(QIODevice.OpenModeFlag.WriteOnly)
func = getattr(pyqiodev, method)
with pytest.raises(OSError, match="Trying to read unreadable file!"):
func()
def test_unwritable(self, pyqiodev):
"""Test writing with a read-only device."""
- pyqiodev.open(QIODevice.ReadOnly)
+ pyqiodev.open(QIODevice.OpenModeFlag.ReadOnly)
with pytest.raises(OSError, match="Trying to write to unwritable "
"file!"):
pyqiodev.write(b'')
@@ -678,7 +678,7 @@ class TestPyQIODevice:
data: The data to write before checking if the length equals
len(data).
"""
- pyqiodev.open(QIODevice.WriteOnly)
+ pyqiodev.open(QIODevice.OpenModeFlag.WriteOnly)
pyqiodev.write(data)
assert len(pyqiodev) == len(data)
@@ -687,8 +687,8 @@ class TestPyQIODevice:
qf = QFile(str(tmp_path))
dev = qtutils.PyQIODevice(qf)
with pytest.raises(qtutils.QtOSError) as excinfo:
- dev.open(QIODevice.WriteOnly)
- assert excinfo.value.qt_errno == QFileDevice.OpenError
+ dev.open(QIODevice.OpenModeFlag.WriteOnly)
+ assert excinfo.value.qt_errno == QFileDevice.FileError.OpenError
assert dev.closed
def test_fileno(self, pyqiodev):
@@ -717,9 +717,9 @@ class TestPyQIODevice:
data: The expected data to read after seeking.
raising: Whether seeking should raise OSError.
"""
- with pyqiodev.open(QIODevice.WriteOnly) as f:
+ with pyqiodev.open(QIODevice.OpenModeFlag.WriteOnly) as f:
f.write(b'1234567890')
- pyqiodev.open(QIODevice.ReadOnly)
+ pyqiodev.open(QIODevice.OpenModeFlag.ReadOnly)
if raising:
with pytest.raises(OSError, match="seek failed!"):
pyqiodev.seek(offset, whence)
@@ -738,7 +738,7 @@ class TestPyQIODevice:
# pylint: enable=no-member,useless-suppression
else:
pytest.skip("Needs os.SEEK_HOLE or os.SEEK_DATA available.")
- pyqiodev.open(QIODevice.ReadOnly)
+ pyqiodev.open(QIODevice.OpenModeFlag.ReadOnly)
with pytest.raises(io.UnsupportedOperation):
pyqiodev.seek(0, whence)
@@ -767,7 +767,7 @@ class TestPyQIODevice:
def test_closed(self, pyqiodev):
"""Test the closed attribute."""
assert pyqiodev.closed
- pyqiodev.open(QIODevice.ReadOnly)
+ pyqiodev.open(QIODevice.OpenModeFlag.ReadOnly)
assert not pyqiodev.closed
pyqiodev.close()
assert pyqiodev.closed
@@ -775,14 +775,14 @@ class TestPyQIODevice:
def test_contextmanager(self, pyqiodev):
"""Make sure using the PyQIODevice as context manager works."""
assert pyqiodev.closed
- with pyqiodev.open(QIODevice.ReadOnly) as f:
+ with pyqiodev.open(QIODevice.OpenModeFlag.ReadOnly) as f:
assert not f.closed
assert f is pyqiodev
assert pyqiodev.closed
def test_flush(self, pyqiodev):
"""Make sure flushing doesn't raise an exception."""
- pyqiodev.open(QIODevice.WriteOnly)
+ pyqiodev.open(QIODevice.OpenModeFlag.WriteOnly)
pyqiodev.write(b'test')
pyqiodev.flush()
@@ -797,14 +797,14 @@ class TestPyQIODevice:
method: The name of the method to call.
ret: The return value we expect.
"""
- pyqiodev.open(QIODevice.WriteOnly)
+ pyqiodev.open(QIODevice.OpenModeFlag.WriteOnly)
func = getattr(pyqiodev, method)
assert func() == ret
@pytest.mark.parametrize('mode, readable, writable', [
- (QIODevice.ReadOnly, True, False),
- (QIODevice.ReadWrite, True, True),
- (QIODevice.WriteOnly, False, True),
+ (QIODevice.OpenModeFlag.ReadOnly, True, False),
+ (QIODevice.OpenModeFlag.ReadWrite, True, True),
+ (QIODevice.OpenModeFlag.WriteOnly, False, True),
])
def test_readable_writable(self, mode, readable, writable, pyqiodev):
"""Test readable() and writable().
@@ -833,19 +833,19 @@ class TestPyQIODevice:
size: The size to pass to readline()
chunks: A list of expected chunks to read.
"""
- with pyqiodev.open(QIODevice.WriteOnly) as f:
+ with pyqiodev.open(QIODevice.OpenModeFlag.WriteOnly) as f:
f.write(b'one\ntwo\nthree')
- pyqiodev.open(QIODevice.ReadOnly)
+ pyqiodev.open(QIODevice.OpenModeFlag.ReadOnly)
for i, chunk in enumerate(chunks, start=1):
print("Expecting chunk {}: {!r}".format(i, chunk))
assert pyqiodev.readline(size) == chunk
def test_write(self, pyqiodev):
"""Make sure writing and re-reading works."""
- with pyqiodev.open(QIODevice.WriteOnly) as f:
+ with pyqiodev.open(QIODevice.OpenModeFlag.WriteOnly) as f:
f.write(b'foo\n')
f.write(b'bar\n')
- pyqiodev.open(QIODevice.ReadOnly)
+ pyqiodev.open(QIODevice.OpenModeFlag.ReadOnly)
assert pyqiodev.read() == b'foo\nbar\n'
def test_write_error(self, pyqiodev_failing):
@@ -859,7 +859,7 @@ class TestPyQIODevice:
def test_write_error_real(self):
"""Test a real write error with /dev/full on supported systems."""
qf = QFile('/dev/full')
- qf.open(QIODevice.WriteOnly | QIODevice.Unbuffered)
+ qf.open(QIODevice.OpenModeFlag.WriteOnly | QIODevice.OpenModeFlag.Unbuffered)
dev = qtutils.PyQIODevice(qf)
with pytest.raises(OSError, match='No space left on device'):
dev.write(b'foo')
@@ -878,9 +878,9 @@ class TestPyQIODevice:
size: The size to pass to read()
chunks: A list of expected data chunks.
"""
- with pyqiodev.open(QIODevice.WriteOnly) as f:
+ with pyqiodev.open(QIODevice.OpenModeFlag.WriteOnly) as f:
f.write(b'1234567890')
- pyqiodev.open(QIODevice.ReadOnly)
+ pyqiodev.open(QIODevice.OpenModeFlag.ReadOnly)
for i, chunk in enumerate(chunks):
print("Expecting chunk {}: {!r}".format(i, chunk))
assert pyqiodev.read(size) == chunk
@@ -974,9 +974,9 @@ class TestInterpolateColor:
def test_invalid_colorspace(self, colors):
"""Test an invalid colorspace."""
with pytest.raises(ValueError):
- qtutils.interpolate_color(colors.white, colors.black, 10, QColor.Cmyk)
+ qtutils.interpolate_color(colors.white, colors.black, 10, QColor.Spec.Cmyk)
- @pytest.mark.parametrize('colorspace', [QColor.Rgb, QColor.Hsv, QColor.Hsl])
+ @pytest.mark.parametrize('colorspace', [QColor.Spec.Rgb, QColor.Spec.Hsv, QColor.Spec.Hsl])
def test_0_100(self, colors, colorspace):
"""Test 0% and 100% in different colorspaces."""
white = qtutils.interpolate_color(colors.white, colors.black, 0, colorspace)
@@ -987,7 +987,7 @@ class TestInterpolateColor:
def test_interpolation_rgb(self):
"""Test an interpolation in the RGB colorspace."""
color = qtutils.interpolate_color(
- testutils.Color(0, 40, 100), testutils.Color(0, 20, 200), 50, QColor.Rgb)
+ testutils.Color(0, 40, 100), testutils.Color(0, 20, 200), 50, QColor.Spec.Rgb)
assert testutils.Color(color) == testutils.Color(0, 30, 150)
def test_interpolation_hsv(self):
@@ -996,7 +996,7 @@ class TestInterpolateColor:
stop = testutils.Color()
start.setHsv(0, 40, 100)
stop.setHsv(0, 20, 200)
- color = qtutils.interpolate_color(start, stop, 50, QColor.Hsv)
+ color = qtutils.interpolate_color(start, stop, 50, QColor.Spec.Hsv)
expected = testutils.Color()
expected.setHsv(0, 30, 150)
assert testutils.Color(color) == expected
@@ -1007,12 +1007,12 @@ class TestInterpolateColor:
stop = testutils.Color()
start.setHsl(0, 40, 100)
stop.setHsl(0, 20, 200)
- color = qtutils.interpolate_color(start, stop, 50, QColor.Hsl)
+ color = qtutils.interpolate_color(start, stop, 50, QColor.Spec.Hsl)
expected = testutils.Color()
expected.setHsl(0, 30, 150)
assert testutils.Color(color) == expected
- @pytest.mark.parametrize('colorspace', [QColor.Rgb, QColor.Hsv, QColor.Hsl])
+ @pytest.mark.parametrize('colorspace', [QColor.Spec.Rgb, QColor.Spec.Hsv, QColor.Spec.Hsl])
def test_interpolation_alpha(self, colorspace):
"""Test interpolation of colorspace's alpha."""
start = testutils.Color(0, 0, 0, 30)
diff --git a/tests/unit/utils/test_standarddir.py b/tests/unit/utils/test_standarddir.py
index 4367a8366..d408bd1fc 100644
--- a/tests/unit/utils/test_standarddir.py
+++ b/tests/unit/utils/test_standarddir.py
@@ -114,8 +114,8 @@ def test_fake_windows(tmpdir, monkeypatch, what):
def test_fake_haiku(tmpdir, monkeypatch):
"""Test getting data dir on HaikuOS."""
locations = {
- QStandardPaths.AppDataLocation: '',
- QStandardPaths.ConfigLocation: str(tmpdir / 'config' / APPNAME),
+ QStandardPaths.StandardLocation.AppDataLocation: '',
+ QStandardPaths.StandardLocation.ConfigLocation: str(tmpdir / 'config' / APPNAME),
}
monkeypatch.setattr(standarddir.QStandardPaths, 'writableLocation',
locations.get)
@@ -135,14 +135,14 @@ class TestWritableLocation:
'qutebrowser.utils.standarddir.QStandardPaths.writableLocation',
lambda typ: '')
with pytest.raises(standarddir.EmptyValueError):
- standarddir._writable_location(QStandardPaths.AppDataLocation)
+ standarddir._writable_location(QStandardPaths.StandardLocation.AppDataLocation)
def test_sep(self, monkeypatch):
"""Make sure the right kind of separator is used."""
monkeypatch.setattr(standarddir.os, 'sep', '\\')
monkeypatch.setattr(standarddir.os.path, 'join',
lambda *parts: '\\'.join(parts))
- loc = standarddir._writable_location(QStandardPaths.AppDataLocation)
+ loc = standarddir._writable_location(QStandardPaths.StandardLocation.AppDataLocation)
assert '/' not in loc
assert '\\' in loc
diff --git a/tests/unit/utils/test_urlutils.py b/tests/unit/utils/test_urlutils.py
index 07df7f6d5..54b95e256 100644
--- a/tests/unit/utils/test_urlutils.py
+++ b/tests/unit/utils/test_urlutils.py
@@ -321,7 +321,7 @@ def test_get_search_url_for_path_search(config_stub, url, host, path, open_base_
config_stub.val.url.open_base_url = open_base_url
url = urlutils._get_search_url(url)
assert url.host() == host
- assert url.path(options=QUrl.PrettyDecoded) == '/' + path
+ assert url.path(options=QUrl.ComponentFormattingOption.PrettyDecoded) == '/' + path
@pytest.mark.parametrize('url, host', [
@@ -704,20 +704,20 @@ class TestProxyFromUrl:
@pytest.mark.parametrize('url, expected', [
('socks://example.com/',
- QNetworkProxy(QNetworkProxy.Socks5Proxy, 'example.com')),
+ QNetworkProxy(QNetworkProxy.ProxyType.Socks5Proxy, 'example.com')),
('socks5://example.com',
- QNetworkProxy(QNetworkProxy.Socks5Proxy, 'example.com')),
+ QNetworkProxy(QNetworkProxy.ProxyType.Socks5Proxy, 'example.com')),
('socks5://example.com:2342',
- QNetworkProxy(QNetworkProxy.Socks5Proxy, 'example.com', 2342)),
+ QNetworkProxy(QNetworkProxy.ProxyType.Socks5Proxy, 'example.com', 2342)),
('socks5://foo@example.com',
- QNetworkProxy(QNetworkProxy.Socks5Proxy, 'example.com', 0, 'foo')),
+ QNetworkProxy(QNetworkProxy.ProxyType.Socks5Proxy, 'example.com', 0, 'foo')),
('socks5://foo:bar@example.com',
- QNetworkProxy(QNetworkProxy.Socks5Proxy, 'example.com', 0, 'foo',
+ QNetworkProxy(QNetworkProxy.ProxyType.Socks5Proxy, 'example.com', 0, 'foo',
'bar')),
('socks5://foo:bar@example.com:2323',
- QNetworkProxy(QNetworkProxy.Socks5Proxy, 'example.com', 2323,
+ QNetworkProxy(QNetworkProxy.ProxyType.Socks5Proxy, 'example.com', 2323,
'foo', 'bar')),
- ('direct://', QNetworkProxy(QNetworkProxy.NoProxy)),
+ ('direct://', QNetworkProxy(QNetworkProxy.ProxyType.NoProxy)),
])
def test_proxy_from_url_valid(self, url, expected):
assert urlutils.proxy_from_url(QUrl(url)) == expected
diff --git a/tests/unit/utils/test_utils.py b/tests/unit/utils/test_utils.py
index e721a2866..b3941d597 100644
--- a/tests/unit/utils/test_utils.py
+++ b/tests/unit/utils/test_utils.py
@@ -659,7 +659,7 @@ class TestGetSetClipboard:
def test_set(self, clipboard_mock, caplog):
utils.set_clipboard('Hello World')
clipboard_mock.setText.assert_called_with('Hello World',
- mode=QClipboard.Clipboard)
+ mode=QClipboard.Mode.Clipboard)
assert not caplog.records
def test_set_unsupported_selection(self, clipboard_mock):