Update no-warning tests for pytest-8 (#622)
Replace the deprecated `pytest.warns(None)` with the suggested replacement (from https://github.com/pytest-dev/pytest/issues/9404) to make the test suite forward compatible with pytest-8. This works correctly with pytest-6 as well.
This commit is contained in:
parent
1161803069
commit
32d642d2a0
@ -35,18 +35,16 @@ def test_message_with_deprecated_field(message):
|
|||||||
|
|
||||||
|
|
||||||
def test_message_with_deprecated_field_not_set(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)
|
Test(value=10)
|
||||||
|
|
||||||
assert not record
|
|
||||||
|
|
||||||
|
|
||||||
def test_message_with_deprecated_field_not_set_default(message):
|
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
|
_ = Test(value=10).message
|
||||||
|
|
||||||
assert not record
|
|
||||||
|
|
||||||
|
|
||||||
@pytest.mark.asyncio
|
@pytest.mark.asyncio
|
||||||
async def test_service_with_deprecated_method():
|
async def test_service_with_deprecated_method():
|
||||||
@ -58,7 +56,6 @@ async def test_service_with_deprecated_method():
|
|||||||
assert len(record) == 1
|
assert len(record) == 1
|
||||||
assert str(record[0].message) == f"TestService.deprecated_func is deprecated"
|
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())
|
await stub.func(Empty())
|
||||||
|
|
||||||
assert not record
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user