Skip to content

Commit a7a2ee0

Browse files
committed
Fix warning filter
1 parent 479b834 commit a7a2ee0

File tree

3 files changed

+30
-1
lines changed

3 files changed

+30
-1
lines changed

graphdatascience/error/cypher_warning_handler.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ def wrapper(self: CallerBase, *args: Any, **kwargs: Any) -> Any:
2424
# since 2025.06 The query used a deprecated function. ('id' has been replaced by 'elementId or consider using an application-generated id')
2525
warnings.filterwarnings(
2626
"ignore",
27-
message=r"ˆThe query used a deprecated function. \('id'.*",
27+
message=r"The query used a deprecated function. \('id'.*",
2828
)
2929

3030
return func(self, *args, **kwargs)

graphdatascience/tests/unit/error/__init__.py

Whitespace-only changes.
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
import warnings
2+
3+
import pytest
4+
5+
from graphdatascience.caller_base import CallerBase
6+
from graphdatascience.error.cypher_warning_handler import filter_id_func_deprecation_warning
7+
8+
9+
class DummyCaller(CallerBase):
10+
def __init__(self) -> None:
11+
super().__init__(None, None, None) # type: ignore
12+
13+
@filter_id_func_deprecation_warning()
14+
def func_with_warning(self) -> str:
15+
warnings.warn(DeprecationWarning("The query used a deprecated function: `id`."))
16+
warnings.warn(
17+
DeprecationWarning(
18+
"The query used a deprecated function. ('id' has been replaced by 'elementId or an application-generated id')"
19+
)
20+
)
21+
warnings.warn(UserWarning("Some other warning"))
22+
return "done"
23+
24+
25+
@pytest.mark.filterwarnings("ignore:Some other warning")
26+
def test_filter_id_func_deprecation_warning_filters_specific_warnings() -> None:
27+
result = DummyCaller().func_with_warning()
28+
# Only the unrelated warning should be present
29+
assert result == "done"

0 commit comments

Comments
 (0)