Skip to content

Commit a0fbcf1

Browse files
committed
Fix match strings containing metacharacters
1 parent c1082d7 commit a0fbcf1

3 files changed

Lines changed: 5 additions & 3 deletions

File tree

tests/cicd_utils/test_scripts/test_extract_latest_release_notes.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
from __future__ import annotations
22

3+
import re
34
from pathlib import Path
45
from typing import TYPE_CHECKING
56

@@ -21,7 +22,7 @@ def test_path_to_changelog_exists() -> None:
2122

2223

2324
def test_extract_latest_release_notes_file_not_found() -> None:
24-
with pytest.raises(FileNotFoundError, match="File not found: non_existent_file.md"):
25+
with pytest.raises(FileNotFoundError, match=re.escape("File not found: non_existent_file.md")):
2526
extract_latest_release_notes(changelog=Path("non_existent_file.md"))
2627

2728

tests/unit/obj/traces/test_init.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
from __future__ import annotations
22

3+
import re
34
from typing import TYPE_CHECKING
45

56
import pytest
@@ -23,6 +24,6 @@ def test_get_trace_cls(name: TraceType, cls: type[RidgeplotTrace]) -> None:
2324

2425
def test_get_trace_cls_unknown() -> None:
2526
with pytest.raises(
26-
ValueError, match="Unknown trace type 'foo'. Available types: 'area', 'bar'."
27+
ValueError, match=re.escape("Unknown trace type 'foo'. Available types: 'area', 'bar'.")
2728
):
2829
get_trace_cls("foo") # pyright: ignore[reportArgumentType]

tests/unit/test_ridgeplot.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -108,7 +108,7 @@ def test_row_labels_wrong_len(row_labels: Any) -> None:
108108
[(1, 4), (2, 4), (3, 2)], # Trace 5
109109
],
110110
]
111-
with pytest.raises(ValueError, match="Expected 2 row_labels, got .* instead"):
111+
with pytest.raises(ValueError, match=r"Expected 2 row_labels, got .* instead"):
112112
ridgeplot(densities=densities, row_labels=row_labels)
113113

114114

0 commit comments

Comments
 (0)