fix pytest 7 warnings
This commit is contained in:
parent
6f7d99ce4b
commit
426a1e25b7
2 changed files with 16 additions and 4 deletions
|
|
@ -3,6 +3,7 @@ import re
|
||||||
import sys
|
import sys
|
||||||
import time
|
import time
|
||||||
import uuid
|
import uuid
|
||||||
|
import warnings
|
||||||
import weakref
|
import weakref
|
||||||
from datetime import datetime
|
from datetime import datetime
|
||||||
from platform import python_implementation
|
from platform import python_implementation
|
||||||
|
|
@ -1527,8 +1528,11 @@ def test_server_name_subdomain():
|
||||||
rv = client.get("/", "https://dev.local")
|
rv = client.get("/", "https://dev.local")
|
||||||
assert rv.data == b"default"
|
assert rv.data == b"default"
|
||||||
|
|
||||||
# suppress Werkzeug 1.0 warning about name mismatch
|
# suppress Werkzeug 0.15 warning about name mismatch
|
||||||
with pytest.warns(None):
|
with warnings.catch_warnings():
|
||||||
|
warnings.filterwarnings(
|
||||||
|
"ignore", "Current server name", UserWarning, "flask.app"
|
||||||
|
)
|
||||||
rv = client.get("/", "http://foo.localhost")
|
rv = client.get("/", "http://foo.localhost")
|
||||||
assert rv.status_code == 404
|
assert rv.status_code == 404
|
||||||
|
|
||||||
|
|
@ -1895,7 +1899,10 @@ def test_subdomain_matching_other_name(matching):
|
||||||
return "", 204
|
return "", 204
|
||||||
|
|
||||||
# suppress Werkzeug 0.15 warning about name mismatch
|
# suppress Werkzeug 0.15 warning about name mismatch
|
||||||
with pytest.warns(None):
|
with warnings.catch_warnings():
|
||||||
|
warnings.filterwarnings(
|
||||||
|
"ignore", "Current server name", UserWarning, "flask.app"
|
||||||
|
)
|
||||||
# ip address can't match name
|
# ip address can't match name
|
||||||
rv = client.get("/", "http://127.0.0.1:3000/")
|
rv = client.get("/", "http://127.0.0.1:3000/")
|
||||||
assert rv.status_code == 404 if matching else 204
|
assert rv.status_code == 404 if matching else 204
|
||||||
|
|
|
||||||
|
|
@ -1,3 +1,5 @@
|
||||||
|
import warnings
|
||||||
|
|
||||||
import pytest
|
import pytest
|
||||||
|
|
||||||
import flask
|
import flask
|
||||||
|
|
@ -81,7 +83,10 @@ def test_proper_test_request_context(app):
|
||||||
)
|
)
|
||||||
|
|
||||||
# suppress Werkzeug 0.15 warning about name mismatch
|
# suppress Werkzeug 0.15 warning about name mismatch
|
||||||
with pytest.warns(None):
|
with warnings.catch_warnings():
|
||||||
|
warnings.filterwarnings(
|
||||||
|
"ignore", "Current server name", UserWarning, "flask.app"
|
||||||
|
)
|
||||||
with app.test_request_context(
|
with app.test_request_context(
|
||||||
"/", environ_overrides={"HTTP_HOST": "localhost"}
|
"/", environ_overrides={"HTTP_HOST": "localhost"}
|
||||||
):
|
):
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue