summaryrefslogtreecommitdiff
path: root/tests/helpers
diff options
context:
space:
mode:
authorFlorian Bruhin <me@the-compiler.org>2021-01-14 11:47:04 +0100
committerFlorian Bruhin <me@the-compiler.org>2021-01-14 11:47:04 +0100
commit482cf9ae047b8a08ee7ad6a1ff64feff39fe6e3c (patch)
treebd9a1784d271b57bd3571f2839100306366eb94d /tests/helpers
parent4d893e75a175d7f05c5627a1dca4e176ce1e70e6 (diff)
parente66968737d433ccc4a5664491e50fad38d5655c3 (diff)
downloadqutebrowser-482cf9ae047b8a08ee7ad6a1ff64feff39fe6e3c.tar.gz
qutebrowser-482cf9ae047b8a08ee7ad6a1ff64feff39fe6e3c.zip
Merge branch 'master' into history-cleanup
# Conflicts: # qutebrowser/app.py
Diffstat (limited to 'tests/helpers')
-rw-r--r--tests/helpers/fixtures.py12
-rw-r--r--tests/helpers/messagemock.py8
-rw-r--r--tests/helpers/stubs.py31
3 files changed, 23 insertions, 28 deletions
diff --git a/tests/helpers/fixtures.py b/tests/helpers/fixtures.py
index b814a6ea7..2d853df08 100644
--- a/tests/helpers/fixtures.py
+++ b/tests/helpers/fixtures.py
@@ -33,8 +33,8 @@ import unittest.mock
import types
import mimetypes
import os.path
+import dataclasses
-import attr
import pytest
import py.path # pylint: disable=no-name-in-module
from PyQt5.QtCore import QSize, Qt
@@ -87,12 +87,12 @@ class WinRegistryHelper:
"""Helper class for win_registry."""
- @attr.s
+ @dataclasses.dataclass
class FakeWindow:
"""A fake window object for the registry."""
- registry = attr.ib()
+ registry: objreg.ObjectRegistry
def windowTitle(self):
return 'window title - qutebrowser'
@@ -276,11 +276,11 @@ def web_tab(request):
def _generate_cmdline_tests():
"""Generate testcases for test_split_binding."""
- @attr.s
+ @dataclasses.dataclass
class TestCase:
- cmd = attr.ib()
- valid = attr.ib()
+ cmd: str
+ valid: bool
separators = [';;', ' ;; ', ';; ', ' ;;']
invalid = ['foo', '']
diff --git a/tests/helpers/messagemock.py b/tests/helpers/messagemock.py
index 03320a98f..8eae9129c 100644
--- a/tests/helpers/messagemock.py
+++ b/tests/helpers/messagemock.py
@@ -20,20 +20,20 @@
"""pytest helper to monkeypatch the message module."""
import logging
+import dataclasses
-import attr
import pytest
from qutebrowser.utils import usertypes, message
-@attr.s
+@dataclasses.dataclass
class Message:
"""Information about a shown message."""
- level = attr.ib()
- text = attr.ib()
+ level: usertypes.MessageLevel
+ text: str
class MessageMock:
diff --git a/tests/helpers/stubs.py b/tests/helpers/stubs.py
index a23d8fd3b..b8dc92540 100644
--- a/tests/helpers/stubs.py
+++ b/tests/helpers/stubs.py
@@ -21,11 +21,12 @@
"""Fake objects/stubs."""
+from typing import Any, Callable, Tuple
from unittest import mock
import contextlib
import shutil
+import dataclasses
-import attr
from PyQt5.QtCore import pyqtSignal, QPoint, QProcess, QObject, QUrl
from PyQt5.QtGui import QIcon
from PyQt5.QtNetwork import (QNetworkRequest, QAbstractNetworkCache,
@@ -116,13 +117,7 @@ class FakeQApplication:
UNSET = object()
def __init__(self, *, style=None, all_widgets=None, active_window=None,
- instance=UNSET, arguments=None, platform_name=None):
-
- if instance is self.UNSET:
- self.instance = mock.Mock(return_value=self)
- else:
- self.instance = mock.Mock(return_value=instance)
-
+ arguments=None, platform_name=None):
self.style = mock.Mock(spec=QCommonStyle)
self.style().metaObject().className.return_value = style
@@ -330,20 +325,20 @@ class FakeSignal:
"""
-@attr.s(frozen=True)
+@dataclasses.dataclass(frozen=True)
class FakeCommand:
"""A simple command stub which has a description."""
- name = attr.ib('')
- desc = attr.ib('')
- hide = attr.ib(False)
- debug = attr.ib(False)
- deprecated = attr.ib(False)
- completion = attr.ib(None)
- maxsplit = attr.ib(None)
- takes_count = attr.ib(lambda: False)
- modes = attr.ib((usertypes.KeyMode.normal, ))
+ name: str = ''
+ desc: str = ''
+ hide: bool = False
+ debug: bool = False
+ deprecated: bool = False
+ completion: Any = None
+ maxsplit: int = None
+ takes_count: Callable[[], bool] = lambda: False
+ modes: Tuple[usertypes.KeyMode] = (usertypes.KeyMode.normal, )
class FakeTimer(QObject):