summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorFlorian Bruhin <me@the-compiler.org>2024-04-30 19:24:25 +0200
committerFlorian Bruhin <me@the-compiler.org>2024-04-30 19:24:25 +0200
commit3d96fc2656b372474c4f302617333bf2bb3e9cde (patch)
tree25fc6ee188aaadb1128e3cd956c5beed828d372e /tests
parent4fdc32ffe13fee65d2e0fe1ac697197089e09bad (diff)
downloadqutebrowser-3d96fc2656b372474c4f302617333bf2bb3e9cde.tar.gz
qutebrowser-3d96fc2656b372474c4f302617333bf2bb3e9cde.zip
Make qt.machinery.Unavailable inherit ModuleNotFoundError
With pytest 8.2, pytest.importorskip(...) now only considers ModuleNotFoundError rather than all ImportErrors, and warns otherwise: https://github.com/pytest-dev/pytest/pull/12220 While we could override this via pytest.importorskip(..., exc_type=machinery.Unavailable) this is a simpler solution, and it also makes more sense semantically: We only raise Unavailable when an import is being done that would otherwise result in a ModuleNotFoundError anyways (e.g. trying to import QtWebKit on Qt 6).
Diffstat (limited to 'tests')
-rw-r--r--tests/unit/test_qt_machinery.py12
1 files changed, 6 insertions, 6 deletions
diff --git a/tests/unit/test_qt_machinery.py b/tests/unit/test_qt_machinery.py
index 25fc83ffd..cf7990393 100644
--- a/tests/unit/test_qt_machinery.py
+++ b/tests/unit/test_qt_machinery.py
@@ -9,7 +9,7 @@ import sys
import html
import argparse
import typing
-from typing import Any, Optional, List, Dict, Union
+from typing import Any, Optional, List, Dict, Union, Type
import dataclasses
import pytest
@@ -45,14 +45,14 @@ def undo_init(monkeypatch: pytest.MonkeyPatch) -> None:
@pytest.mark.parametrize(
- "exception",
+ "exception, base",
[
- machinery.Unavailable(),
- machinery.NoWrapperAvailableError(machinery.SelectionInfo()),
+ (machinery.Unavailable(), ModuleNotFoundError),
+ (machinery.NoWrapperAvailableError(machinery.SelectionInfo()), ImportError),
],
)
-def test_importerror_exceptions(exception: Exception):
- with pytest.raises(ImportError):
+def test_importerror_exceptions(exception: Exception, base: Type[Exception]):
+ with pytest.raises(base):
raise exception