75 lines
2.8 KiB
Diff
75 lines
2.8 KiB
Diff
From 4201d0f6d1b337a0e69900a79042215896eede4a Mon Sep 17 00:00:00 2001
|
|
From: =?UTF-8?q?Micha=C5=82=20G=C3=B3rny?= <mgorny@gentoo.org>
|
|
Date: Sat, 19 Jun 2021 09:51:43 +0200
|
|
Subject: [PATCH] Fix warning tests to work correctly without -Werror
|
|
|
|
Use pytest.warns() instead of pytest.raises() to test for warnings,
|
|
in order to make these tests work correctly without -Werror. This does
|
|
not change the behavior with -Werror.
|
|
|
|
While -Werror is useful for package maintainers / CI, it is problematic
|
|
for testing on end user systems. For end users, it is important whether
|
|
the particular version of package is going to work on their setup,
|
|
not whether it does not use anything that's deprecated but still
|
|
working.
|
|
---
|
|
CHANGES.rst | 2 ++
|
|
tests/test_wrappers.py | 12 ++++++------
|
|
2 files changed, 8 insertions(+), 6 deletions(-)
|
|
|
|
diff --git a/CHANGES.rst b/CHANGES.rst
|
|
index 8fa1e454..9a05145f 100644
|
|
--- a/CHANGES.rst
|
|
+++ b/CHANGES.rst
|
|
@@ -5,6 +5,8 @@ Version 2.1.0
|
|
|
|
Unreleased
|
|
|
|
+- Fix warning tests to work correctly without -Werror
|
|
+
|
|
|
|
Version 2.0.2
|
|
-------------
|
|
diff --git a/tests/test_wrappers.py b/tests/test_wrappers.py
|
|
index 3ac80003..fe8c01f3 100644
|
|
--- a/tests/test_wrappers.py
|
|
+++ b/tests/test_wrappers.py
|
|
@@ -1633,29 +1633,29 @@ def test_response_mixins_deprecated(cls):
|
|
class CheckResponse(cls, wrappers.Response):
|
|
pass
|
|
|
|
- with pytest.raises(DeprecationWarning, match=cls.__name__):
|
|
+ with pytest.warns(DeprecationWarning, match=cls.__name__):
|
|
CheckResponse()
|
|
|
|
|
|
def test_check_base_deprecated():
|
|
- with pytest.raises(DeprecationWarning, match=r"issubclass\(cls, Request\)"):
|
|
+ with pytest.warns(DeprecationWarning, match=r"issubclass\(cls, Request\)"):
|
|
assert issubclass(wrappers.Request, wrappers.BaseRequest)
|
|
|
|
- with pytest.raises(DeprecationWarning, match=r"isinstance\(obj, Request\)"):
|
|
+ with pytest.warns(DeprecationWarning, match=r"isinstance\(obj, Request\)"):
|
|
assert isinstance(
|
|
wrappers.Request({"SERVER_NAME": "example.org", "SERVER_PORT": "80"}),
|
|
wrappers.BaseRequest,
|
|
)
|
|
|
|
- with pytest.raises(DeprecationWarning, match=r"issubclass\(cls, Response\)"):
|
|
+ with pytest.warns(DeprecationWarning, match=r"issubclass\(cls, Response\)"):
|
|
assert issubclass(wrappers.Response, wrappers.BaseResponse)
|
|
|
|
- with pytest.raises(DeprecationWarning, match=r"isinstance\(obj, Response\)"):
|
|
+ with pytest.warns(DeprecationWarning, match=r"isinstance\(obj, Response\)"):
|
|
assert isinstance(wrappers.Response(), wrappers.BaseResponse)
|
|
|
|
|
|
def test_response_freeze_no_etag_deprecated():
|
|
- with pytest.raises(DeprecationWarning, match="no_etag"):
|
|
+ with pytest.warns(DeprecationWarning, match="no_etag"):
|
|
Response("Hello, World!").freeze(no_etag=True)
|
|
|
|
|
|
--
|
|
2.32.0
|
|
|