Skip to content

Commit

Permalink
Update no-warning tests for pytest-8 (#622)
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
mgorny authored Oct 5, 2024
1 parent 1161803 commit 32d642d
Showing 1 changed file with 6 additions and 9 deletions.
15 changes: 6 additions & 9 deletions tests/test_deprecated.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,18 +35,16 @@ def test_message_with_deprecated_field(message):


def test_message_with_deprecated_field_not_set(message):
with pytest.warns(None) as record:
with warnings.catch_warnings():
warnings.simplefilter("error")
Test(value=10)

assert not record


def test_message_with_deprecated_field_not_set_default(message):
with pytest.warns(None) as record:
with warnings.catch_warnings():
warnings.simplefilter("error")
_ = Test(value=10).message

assert not record


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

with pytest.warns(None) as record:
with warnings.catch_warnings():
warnings.simplefilter("error")
await stub.func(Empty())

assert not record

0 comments on commit 32d642d

Please sign in to comment.