From 426a1e25b77e760b4f54bf94aee3e3617850569f Mon Sep 17 00:00:00 2001 From: David Lord Date: Tue, 8 Feb 2022 12:05:17 -0800 Subject: [PATCH] fix pytest 7 warnings --- tests/test_basic.py | 13 ++++++++++--- tests/test_reqctx.py | 7 ++++++- 2 files changed, 16 insertions(+), 4 deletions(-) diff --git a/tests/test_basic.py b/tests/test_basic.py index 2cb96794..0188cc54 100644 --- a/tests/test_basic.py +++ b/tests/test_basic.py @@ -3,6 +3,7 @@ import re import sys import time import uuid +import warnings import weakref from datetime import datetime from platform import python_implementation @@ -1527,8 +1528,11 @@ def test_server_name_subdomain(): rv = client.get("/", "https://dev.local") assert rv.data == b"default" - # suppress Werkzeug 1.0 warning about name mismatch - with pytest.warns(None): + # suppress Werkzeug 0.15 warning about name mismatch + with warnings.catch_warnings(): + warnings.filterwarnings( + "ignore", "Current server name", UserWarning, "flask.app" + ) rv = client.get("/", "http://foo.localhost") assert rv.status_code == 404 @@ -1895,7 +1899,10 @@ def test_subdomain_matching_other_name(matching): return "", 204 # 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 rv = client.get("/", "http://127.0.0.1:3000/") assert rv.status_code == 404 if matching else 204 diff --git a/tests/test_reqctx.py b/tests/test_reqctx.py index d18cb509..1a478917 100644 --- a/tests/test_reqctx.py +++ b/tests/test_reqctx.py @@ -1,3 +1,5 @@ +import warnings + import pytest import flask @@ -81,7 +83,10 @@ def test_proper_test_request_context(app): ) # 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( "/", environ_overrides={"HTTP_HOST": "localhost"} ):