sanic/tests/test_deprecation.py

21 lines
516 B
Python
Raw Permalink Normal View History

import pytest
2022-09-18 16:54:35 +01:00
from sanic import Sanic
from sanic.log import deprecation
def test_deprecation():
message = r"\[DEPRECATION v9\.9\] hello"
with pytest.warns(DeprecationWarning, match=message):
deprecation("hello", 9.9)
2022-09-18 16:54:35 +01:00
@pytest.mark.parametrize(
"filter,expected",
(("default", 1), ("once", 1), ("ignore", 0)),
)
def test_deprecation_filter(app: Sanic, filter, expected, recwarn):
app.config.DEPRECATION_FILTER = filter
deprecation("hello", 9.9)
assert len(recwarn) == expected