Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit fe5712d

Browse filesBrowse files
committed
Match generic ValueError's text in tests for Commands
Fixes flake8-pytest-style (Ruff) linter error(s): PT011 `pytest.raises(ValueError)` is too broad, set the `match` parameter or use a more specific exception This is an omission in dca5cdd, because older versions of Ruff omitted them.
1 parent 698dc95 commit fe5712d
Copy full SHA for fe5712d

1 file changed

+22-3Lines changed: 22 additions & 3 deletions

File tree

Expand file treeCollapse file tree
Open diff view settings
Filter options
Expand file treeCollapse file tree
Open diff view settings
Collapse file

‎tests/protocol/test_commands.py‎

Copy file name to clipboardExpand all lines: tests/protocol/test_commands.py
+22-3Lines changed: 22 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66

77
import ipaddress
88
import logging
9+
import re
910
import struct
1011
from typing import TYPE_CHECKING, Any, ClassVar, Final
1112

@@ -826,24 +827,42 @@ def test_command_registry_populated() -> None:
826827

827828

828829
@pytest.mark.parametrize(
829-
"char",
830+
("char", "match_re"),
830831
[
831832
pytest.param(
832833
b"O",
834+
re.compile(
835+
r"Command registration for .* failed; command char b'O' is already "
836+
r"registered to .*\."
837+
),
833838
id="taken-by-OptionsNegotiate",
834839
),
835840
pytest.param(
836841
b"",
842+
re.compile(
843+
r"Command registration for .* failed; command char must be exactly one "
844+
r"byte\."
845+
),
837846
id="length-invalid-zero",
838847
),
839848
pytest.param(
840849
b"ZZ",
850+
re.compile(
851+
r"Command registration for .* failed; command char must be exactly one "
852+
r"byte\."
853+
),
841854
id="length-invalid-more-than-one",
842855
),
843856
],
844857
)
845-
def test_command_registry_fails_definition_time(char: bytes) -> None:
846-
with pytest.raises(ValueError):
858+
def test_command_registry_fails_definition_time(
859+
char: bytes,
860+
match_re: re.Pattern[str],
861+
) -> None:
862+
with pytest.raises(
863+
ValueError,
864+
match=match_re,
865+
):
847866

848867
class CommandWithCharInvalid( # pyright: ignore PylancereportUnusedClass
849868
BaseCommand

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.