diff options
author | Florian Bruhin <me@the-compiler.org> | 2021-01-11 22:22:30 +0100 |
---|---|---|
committer | Florian Bruhin <me@the-compiler.org> | 2021-01-13 20:26:41 +0100 |
commit | c970c6335521fee359c1a68c0431c612631e73fb (patch) | |
tree | 1062d9ffd9fbfcafc0753308b8e7a15a5f5f6920 /tests/helpers | |
parent | 4b7d52ae7cdf52ebef038b4a90b9fe95ab002105 (diff) | |
download | qutebrowser-c970c6335521fee359c1a68c0431c612631e73fb.tar.gz qutebrowser-c970c6335521fee359c1a68c0431c612631e73fb.zip |
dataclasses: Initial switch
See #6023
Diffstat (limited to 'tests/helpers')
-rw-r--r-- | tests/helpers/fixtures.py | 12 | ||||
-rw-r--r-- | tests/helpers/messagemock.py | 8 | ||||
-rw-r--r-- | tests/helpers/stubs.py | 23 |
3 files changed, 22 insertions, 21 deletions
diff --git a/tests/helpers/fixtures.py b/tests/helpers/fixtures.py index b814a6ea7..c62c9960b 100644 --- a/tests/helpers/fixtures.py +++ b/tests/helpers/fixtures.py @@ -34,7 +34,7 @@ import types import mimetypes import os.path -import attr +import dataclasses 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..72f170408 100644 --- a/tests/helpers/messagemock.py +++ b/tests/helpers/messagemock.py @@ -21,19 +21,19 @@ import logging -import attr +import dataclasses 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 997f160ce..0e4dd3b92 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, @@ -324,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): |