Skip to content

Commit f891957

Browse files
committed
Update no-warning tests for pytest-8
Replace the deprecated `pytest.warns(None)` with the suggested replacement (from pytest-dev/pytest#9404) to make the test suite forward compatible with pytest-8. This works correctly with pytest-6 as well.
1 parent 1161803 commit f891957

File tree

1 file changed

+6
-9
lines changed

1 file changed

+6
-9
lines changed

tests/test_deprecated.py

Lines changed: 6 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -35,18 +35,16 @@ def test_message_with_deprecated_field(message):
3535

3636

3737
def test_message_with_deprecated_field_not_set(message):
38-
with pytest.warns(None) as record:
38+
with warnings.catch_warnings():
39+
warnings.simplefilter("error")
3940
Test(value=10)
4041

41-
assert not record
42-
4342

4443
def test_message_with_deprecated_field_not_set_default(message):
45-
with pytest.warns(None) as record:
44+
with warnings.catch_warnings():
45+
warnings.simplefilter("error")
4646
_ = Test(value=10).message
4747

48-
assert not record
49-
5048

5149
@pytest.mark.asyncio
5250
async def test_service_with_deprecated_method():
@@ -58,7 +56,6 @@ async def test_service_with_deprecated_method():
5856
assert len(record) == 1
5957
assert str(record[0].message) == f"TestService.deprecated_func is deprecated"
6058

61-
with pytest.warns(None) as record:
59+
with warnings.catch_warnings():
60+
warnings.simplefilter("error")
6261
await stub.func(Empty())
63-
64-
assert not record

0 commit comments

Comments
 (0)