Add deprecation warning filter (#2546)
This commit is contained in:
@@ -1,5 +1,6 @@
|
||||
import pytest
|
||||
|
||||
from sanic import Sanic
|
||||
from sanic.log import deprecation
|
||||
|
||||
|
||||
@@ -7,3 +8,13 @@ def test_deprecation():
|
||||
message = r"\[DEPRECATION v9\.9\] hello"
|
||||
with pytest.warns(DeprecationWarning, match=message):
|
||||
deprecation("hello", 9.9)
|
||||
|
||||
|
||||
@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
|
||||
|
||||
Reference in New Issue
Block a user