summaryrefslogtreecommitdiff
path: root/tests/unit/config/test_configtypes.py
diff options
context:
space:
mode:
Diffstat (limited to 'tests/unit/config/test_configtypes.py')
-rw-r--r--tests/unit/config/test_configtypes.py96
1 files changed, 47 insertions, 49 deletions
diff --git a/tests/unit/config/test_configtypes.py b/tests/unit/config/test_configtypes.py
index c34efce54..37a077775 100644
--- a/tests/unit/config/test_configtypes.py
+++ b/tests/unit/config/test_configtypes.py
@@ -29,9 +29,7 @@ import dataclasses
import pytest
import hypothesis
from hypothesis import strategies
-from PyQt5.QtCore import QUrl
-from PyQt5.QtGui import QColor, QFont
-from PyQt5.QtNetwork import QNetworkProxy
+from qutebrowser.qt import QtNetwork, QtGui, QtCore
from qutebrowser.misc import objects
from qutebrowser.config import configtypes, configexc
@@ -41,13 +39,13 @@ from qutebrowser.keyinput import keyutils
from helpers import testutils
-class Font(QFont):
+class Font(QtGui.QFont):
"""A QFont with a nicer repr()."""
def __repr__(self):
- weight = debug.qenum_key(QFont, self.weight(), add_base=True,
- klass=QFont.Weight)
+ weight = debug.qenum_key(QtGui.QFont, self.weight(), add_base=True,
+ klass=QtGui.QFont.Weight)
kwargs = {
'family': self.family(),
'pt': self.pointSize(),
@@ -1274,20 +1272,20 @@ class TestQtColor:
return configtypes.QtColor
@pytest.mark.parametrize('val, expected', [
- ('#123', QColor('#123')),
- ('#112233', QColor('#112233')),
- ('#44112233', QColor('#44112233')),
- ('#111222333', QColor('#111222333')),
- ('#111122223333', QColor('#111122223333')),
- ('red', QColor('red')),
+ ('#123', QtGui.QColor('#123')),
+ ('#112233', QtGui.QColor('#112233')),
+ ('#44112233', QtGui.QColor('#44112233')),
+ ('#111222333', QtGui.QColor('#111222333')),
+ ('#111122223333', QtGui.QColor('#111122223333')),
+ ('red', QtGui.QColor('red')),
- ('rgb(0, 0, 0)', QColor.fromRgb(0, 0, 0)),
- ('rgb(0,0,0)', QColor.fromRgb(0, 0, 0)),
+ ('rgb(0, 0, 0)', QtGui.QColor.fromRgb(0, 0, 0)),
+ ('rgb(0,0,0)', QtGui.QColor.fromRgb(0, 0, 0)),
- ('rgba(255, 255, 255, 1.0)', QColor.fromRgb(255, 255, 255, 255)),
+ ('rgba(255, 255, 255, 1.0)', QtGui.QColor.fromRgb(255, 255, 255, 255)),
- ('hsv(10%,10%,10%)', QColor.fromHsv(35, 25, 25)),
- ('hsva(10%,20%,30%,40%)', QColor.fromHsv(35, 51, 76, 102)),
+ ('hsv(10%,10%,10%)', QtGui.QColor.fromHsv(35, 25, 25)),
+ ('hsva(10%,20%,30%,40%)', QtGui.QColor.fromHsv(35, 51, 76, 102)),
])
def test_valid(self, klass, val, expected):
assert klass().to_py(val) == expected
@@ -1363,8 +1361,8 @@ class TestQssColor:
@dataclasses.dataclass
class FontDesc:
- style: QFont.Style
- weight: QFont.Weight
+ style: QtGui.QFont.Style
+ weight: QtGui.QFont.Weight
pt: int
px: int
family: str
@@ -1375,46 +1373,46 @@ class TestFont:
TESTS = {
# (style, weight, pointsize, pixelsize, family
'"Foobar Neue"':
- FontDesc(QFont.StyleNormal, QFont.Normal, -1, -1, 'Foobar Neue'),
+ FontDesc(QtGui.QFont.StyleNormal, QtGui.QFont.Normal, -1, -1, 'Foobar Neue'),
'inconsolatazi4':
- FontDesc(QFont.StyleNormal, QFont.Normal, -1, -1,
+ FontDesc(QtGui.QFont.StyleNormal, QtGui.QFont.Normal, -1, -1,
'inconsolatazi4'),
'Terminus (TTF)':
- FontDesc(QFont.StyleNormal, QFont.Normal, -1, -1,
+ FontDesc(QtGui.QFont.StyleNormal, QtGui.QFont.Normal, -1, -1,
'Terminus (TTF)'),
'10pt "Foobar Neue"':
- FontDesc(QFont.StyleNormal, QFont.Normal, 10, None, 'Foobar Neue'),
+ FontDesc(QtGui.QFont.StyleNormal, QtGui.QFont.Normal, 10, None, 'Foobar Neue'),
'10PT "Foobar Neue"':
- FontDesc(QFont.StyleNormal, QFont.Normal, 10, None, 'Foobar Neue'),
+ FontDesc(QtGui.QFont.StyleNormal, QtGui.QFont.Normal, 10, None, 'Foobar Neue'),
'10px "Foobar Neue"':
- FontDesc(QFont.StyleNormal, QFont.Normal, None, 10, 'Foobar Neue'),
+ FontDesc(QtGui.QFont.StyleNormal, QtGui.QFont.Normal, None, 10, 'Foobar Neue'),
'10PX "Foobar Neue"':
- FontDesc(QFont.StyleNormal, QFont.Normal, None, 10, 'Foobar Neue'),
+ FontDesc(QtGui.QFont.StyleNormal, QtGui.QFont.Normal, None, 10, 'Foobar Neue'),
'bold "Foobar Neue"':
- FontDesc(QFont.StyleNormal, QFont.Bold, -1, -1, 'Foobar Neue'),
+ FontDesc(QtGui.QFont.StyleNormal, QtGui.QFont.Bold, -1, -1, 'Foobar Neue'),
'italic "Foobar Neue"':
- FontDesc(QFont.StyleItalic, QFont.Normal, -1, -1, 'Foobar Neue'),
+ FontDesc(QtGui.QFont.StyleItalic, QtGui.QFont.Normal, -1, -1, 'Foobar Neue'),
'oblique "Foobar Neue"':
- FontDesc(QFont.StyleOblique, QFont.Normal, -1, -1, 'Foobar Neue'),
+ FontDesc(QtGui.QFont.StyleOblique, QtGui.QFont.Normal, -1, -1, 'Foobar Neue'),
'normal bold "Foobar Neue"':
- FontDesc(QFont.StyleNormal, QFont.Bold, -1, -1, 'Foobar Neue'),
+ FontDesc(QtGui.QFont.StyleNormal, QtGui.QFont.Bold, -1, -1, 'Foobar Neue'),
'bold italic "Foobar Neue"':
- FontDesc(QFont.StyleItalic, QFont.Bold, -1, -1, 'Foobar Neue'),
+ FontDesc(QtGui.QFont.StyleItalic, QtGui.QFont.Bold, -1, -1, 'Foobar Neue'),
'bold 10pt "Foobar Neue"':
- FontDesc(QFont.StyleNormal, QFont.Bold, 10, None, 'Foobar Neue'),
+ FontDesc(QtGui.QFont.StyleNormal, QtGui.QFont.Bold, 10, None, 'Foobar Neue'),
'italic 10pt "Foobar Neue"':
- FontDesc(QFont.StyleItalic, QFont.Normal, 10, None, 'Foobar Neue'),
+ FontDesc(QtGui.QFont.StyleItalic, QtGui.QFont.Normal, 10, None, 'Foobar Neue'),
'oblique 10pt "Foobar Neue"':
- FontDesc(QFont.StyleOblique, QFont.Normal, 10, None,
+ FontDesc(QtGui.QFont.StyleOblique, QtGui.QFont.Normal, 10, None,
'Foobar Neue'),
'normal bold 10pt "Foobar Neue"':
- FontDesc(QFont.StyleNormal, QFont.Bold, 10, None, 'Foobar Neue'),
+ FontDesc(QtGui.QFont.StyleNormal, QtGui.QFont.Bold, 10, None, 'Foobar Neue'),
'bold italic 10pt "Foobar Neue"':
- FontDesc(QFont.StyleItalic, QFont.Bold, 10, None, 'Foobar Neue'),
+ FontDesc(QtGui.QFont.StyleItalic, QtGui.QFont.Bold, 10, None, 'Foobar Neue'),
'normal 300 10pt "Foobar Neue"':
- FontDesc(QFont.StyleNormal, 37, 10, None, 'Foobar Neue'),
+ FontDesc(QtGui.QFont.StyleNormal, 37, 10, None, 'Foobar Neue'),
'normal 800 10pt "Foobar Neue"':
- FontDesc(QFont.StyleNormal, 99, 10, None, 'Foobar Neue'),
+ FontDesc(QtGui.QFont.StyleNormal, 99, 10, None, 'Foobar Neue'),
}
font_xfail = pytest.mark.xfail(reason='FIXME: #103')
@@ -1891,21 +1889,21 @@ class TestProxy:
@pytest.mark.parametrize('val, expected', [
('system', configtypes.SYSTEM_PROXY),
- ('none', QNetworkProxy(QNetworkProxy.NoProxy)),
+ ('none', QtNetwork.QNetworkProxy(QtNetwork.QNetworkProxy.NoProxy)),
('socks://example.com/',
- QNetworkProxy(QNetworkProxy.Socks5Proxy, 'example.com')),
+ QtNetwork.QNetworkProxy(QtNetwork.QNetworkProxy.Socks5Proxy, 'example.com')),
('socks5://foo:bar@example.com:2323',
- QNetworkProxy(QNetworkProxy.Socks5Proxy, 'example.com', 2323,
+ QtNetwork.QNetworkProxy(QtNetwork.QNetworkProxy.Socks5Proxy, 'example.com', 2323,
'foo', 'bar')),
('pac+http://example.com/proxy.pac',
- pac.PACFetcher(QUrl('pac+http://example.com/proxy.pac'))),
+ pac.PACFetcher(QtCore.QUrl('pac+http://example.com/proxy.pac'))),
('pac+file:///tmp/proxy.pac',
- pac.PACFetcher(QUrl('pac+file:///tmp/proxy.pac'))),
+ pac.PACFetcher(QtCore.QUrl('pac+file:///tmp/proxy.pac'))),
])
def test_to_py_valid(self, klass, val, expected):
actual = klass().to_py(val)
- if isinstance(actual, QNetworkProxy):
- actual = QNetworkProxy(actual)
+ if isinstance(actual, QtNetwork.QNetworkProxy):
+ actual = QtNetwork.QNetworkProxy(actual)
assert actual == expected
@pytest.mark.parametrize('val', [
@@ -1958,8 +1956,8 @@ class TestFuzzyUrl:
return configtypes.FuzzyUrl
@pytest.mark.parametrize('val, expected', [
- ('http://example.com/?q={}', QUrl('http://example.com/?q={}')),
- ('example.com', QUrl('http://example.com')),
+ ('http://example.com/?q={}', QtCore.QUrl('http://example.com/?q={}')),
+ ('example.com', QtCore.QUrl('http://example.com')),
])
def test_to_py_valid(self, klass, val, expected):
assert klass().to_py(val) == expected
@@ -2014,8 +2012,8 @@ class TestEncoding:
class TestUrl:
TESTS = {
- 'http://qutebrowser.org/': QUrl('http://qutebrowser.org/'),
- 'http://heise.de/': QUrl('http://heise.de/'),
+ 'http://qutebrowser.org/': QtCore.QUrl('http://qutebrowser.org/'),
+ 'http://heise.de/': QtCore.QUrl('http://heise.de/'),
}
@pytest.fixture