Skip to content

Commit 140b0a8

Browse files
[Test] Update tests to test for deprecation warning
1 parent 2a856fb commit 140b0a8

File tree

1 file changed

+7
-13
lines changed

1 file changed

+7
-13
lines changed

tests/test_utils.py

Lines changed: 7 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -39,17 +39,11 @@ def test_deprecated_docs(function_factory):
3939

4040
def test_deprecated_log_default_message(function_factory):
4141
"""Test deprecated_log with default message using @ syntax."""
42-
sample_func = deprecated_log(function_factory)
43-
44-
with pytest.warns(UserWarning, match="Function sample_func is deprecated and will be removed"):
45-
sample_func()
46-
47-
48-
def test_deprecated_log_with_parentheses(function_factory):
49-
"""Test deprecated_log with default message using @deprecated_log() syntax."""
5042
sample_func = deprecated_log()(function_factory)
5143

52-
with pytest.warns(UserWarning, match="Function sample_func is deprecated and will be removed"):
44+
with pytest.warns(
45+
DeprecationWarning, match="Function sample_func is deprecated and will be removed in future versions"
46+
):
5347
sample_func()
5448

5549

@@ -58,7 +52,7 @@ def test_deprecated_log_custom_message(function_factory):
5852
custom_message = "This function is obsolete. Use new_function() instead."
5953
sample_func = deprecated_log(custom_message)(function_factory)
6054

61-
with pytest.warns(UserWarning, match="This function is obsolete. Use new_function\\(\\) instead."):
55+
with pytest.warns(DeprecationWarning, match="This function is obsolete. Use new_function\\(\\) instead."):
6256
sample_func()
6357

6458

@@ -78,7 +72,7 @@ def func_with_return():
7872

7973
decorated_func = deprecated_log(func_with_return)
8074

81-
with pytest.warns(UserWarning):
75+
with pytest.warns(DeprecationWarning):
8276
result = decorated_func()
8377

8478
assert result == "test_value"
@@ -92,7 +86,7 @@ def func_with_args(a, b, c=None):
9286

9387
decorated_func = deprecated_log(func_with_args)
9488

95-
with pytest.warns(UserWarning):
89+
with pytest.warns(DeprecationWarning):
9690
result = decorated_func(1, 2, c=3)
9791

9892
assert result == (1, 2, 3)
@@ -106,5 +100,5 @@ def sample_func():
106100

107101
decorated_func = deprecated_log(sample_func)
108102

109-
with pytest.warns(UserWarning):
103+
with pytest.warns(DeprecationWarning):
110104
decorated_func()

0 commit comments

Comments
 (0)