From b87efdfa9459dbc3fbe6bbc10a30a910336fbe21 Mon Sep 17 00:00:00 2001 From: Kurt McKee Date: Fri, 12 Jul 2024 15:57:25 -0500 Subject: [PATCH 1/2] Move pytest warning control to `pytest.ini` --- pytest.ini | 2 ++ tasks.py | 8 ++++---- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/pytest.ini b/pytest.ini index f1b716ae96..beb9689865 100644 --- a/pytest.ini +++ b/pytest.ini @@ -11,3 +11,5 @@ markers = experimental: run only experimental tests asyncio_mode = auto timeout = 30 +filterwarnings = + always diff --git a/tasks.py b/tasks.py index 79b27852e3..0fef093f3c 100644 --- a/tasks.py +++ b/tasks.py @@ -55,11 +55,11 @@ def standalone_tests(c, uvloop=False, protocol=2, profile=False): profile_arg = "--profile" if profile else "" if uvloop: run( - f"pytest {profile_arg} --protocol={protocol} --cov=./ --cov-report=xml:coverage_redis.xml -W always -m 'not onlycluster' --uvloop --junit-xml=standalone-uvloop-results.xml" + f"pytest {profile_arg} --protocol={protocol} --cov=./ --cov-report=xml:coverage_redis.xml -m 'not onlycluster' --uvloop --junit-xml=standalone-uvloop-results.xml" ) else: run( - f"pytest {profile_arg} --protocol={protocol} --cov=./ --cov-report=xml:coverage_redis.xml -W always -m 'not onlycluster' --junit-xml=standalone-results.xml" + f"pytest {profile_arg} --protocol={protocol} --cov=./ --cov-report=xml:coverage_redis.xml -m 'not onlycluster' --junit-xml=standalone-results.xml" ) @@ -70,11 +70,11 @@ def cluster_tests(c, uvloop=False, protocol=2, profile=False): cluster_url = "redis://localhost:16379/0" if uvloop: run( - f"pytest {profile_arg} --protocol={protocol} --cov=./ --cov-report=xml:coverage_cluster.xml -W always -m 'not onlynoncluster and not redismod' --redis-url={cluster_url} --junit-xml=cluster-uvloop-results.xml --uvloop" + f"pytest {profile_arg} --protocol={protocol} --cov=./ --cov-report=xml:coverage_cluster.xml -m 'not onlynoncluster and not redismod' --redis-url={cluster_url} --junit-xml=cluster-uvloop-results.xml --uvloop" ) else: run( - f"pytest {profile_arg} --protocol={protocol} --cov=./ --cov-report=xml:coverage_clusteclient.xml -W always -m 'not onlynoncluster and not redismod' --redis-url={cluster_url} --junit-xml=cluster-results.xml" + f"pytest {profile_arg} --protocol={protocol} --cov=./ --cov-report=xml:coverage_clusteclient.xml -m 'not onlynoncluster and not redismod' --redis-url={cluster_url} --junit-xml=cluster-results.xml" ) From 28f8e5ade054105f168206f034740dd123368a7a Mon Sep 17 00:00:00 2001 From: Kurt McKee Date: Fri, 12 Jul 2024 15:58:16 -0500 Subject: [PATCH 2/2] Ignore `Graph` `DeprecationWarning` in the test suite One extra test is added to verify the warning is actually thrown. --- pytest.ini | 1 + tests/test_graph.py | 9 +++++++++ 2 files changed, 10 insertions(+) diff --git a/pytest.ini b/pytest.ini index beb9689865..9db630e5b1 100644 --- a/pytest.ini +++ b/pytest.ini @@ -13,3 +13,4 @@ asyncio_mode = auto timeout = 30 filterwarnings = always + ignore:RedisGraph support is deprecated as of Redis Stack 7.2:DeprecationWarning diff --git a/tests/test_graph.py b/tests/test_graph.py index 680b8af645..c82c5030c8 100644 --- a/tests/test_graph.py +++ b/tests/test_graph.py @@ -40,6 +40,15 @@ def test_bulk(client): client.graph().bulk(foo="bar!") +@pytest.mark.redismod +def test_graph_creation_throws_deprecation_warning(client): + """Verify that a DeprecationWarning is raised when creating a Graph instance.""" + + match = "RedisGraph support is deprecated as of Redis Stack 7.2" + with pytest.warns(DeprecationWarning, match=match): + client.graph() + + @pytest.mark.redismod @skip_if_resp_version(3) def test_graph_creation(client):