Skip to content

Commit b206a0f

Browse files
authored
Suppress Graph deprecation warning in test suite (#3316)
Move pytest warning control to `pytest.ini`. Ignore `Graph` `DeprecationWarning` in the test suite One extra test is added to verify the warning is actually thrown.
1 parent b2179f6 commit b206a0f

File tree

3 files changed

+16
-4
lines changed

3 files changed

+16
-4
lines changed

pytest.ini

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,3 +11,6 @@ markers =
1111
experimental: run only experimental tests
1212
asyncio_mode = auto
1313
timeout = 30
14+
filterwarnings =
15+
always
16+
ignore:RedisGraph support is deprecated as of Redis Stack 7.2:DeprecationWarning

tasks.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -55,11 +55,11 @@ def standalone_tests(c, uvloop=False, protocol=2, profile=False):
5555
profile_arg = "--profile" if profile else ""
5656
if uvloop:
5757
run(
58-
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"
58+
f"pytest {profile_arg} --protocol={protocol} --cov=./ --cov-report=xml:coverage_redis.xml -m 'not onlycluster' --uvloop --junit-xml=standalone-uvloop-results.xml"
5959
)
6060
else:
6161
run(
62-
f"pytest {profile_arg} --protocol={protocol} --cov=./ --cov-report=xml:coverage_redis.xml -W always -m 'not onlycluster' --junit-xml=standalone-results.xml"
62+
f"pytest {profile_arg} --protocol={protocol} --cov=./ --cov-report=xml:coverage_redis.xml -m 'not onlycluster' --junit-xml=standalone-results.xml"
6363
)
6464

6565

@@ -70,11 +70,11 @@ def cluster_tests(c, uvloop=False, protocol=2, profile=False):
7070
cluster_url = "redis://localhost:16379/0"
7171
if uvloop:
7272
run(
73-
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"
73+
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"
7474
)
7575
else:
7676
run(
77-
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"
77+
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"
7878
)
7979

8080

tests/test_graph.py

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,15 @@ def test_bulk(client):
4040
client.graph().bulk(foo="bar!")
4141

4242

43+
@pytest.mark.redismod
44+
def test_graph_creation_throws_deprecation_warning(client):
45+
"""Verify that a DeprecationWarning is raised when creating a Graph instance."""
46+
47+
match = "RedisGraph support is deprecated as of Redis Stack 7.2"
48+
with pytest.warns(DeprecationWarning, match=match):
49+
client.graph()
50+
51+
4352
@pytest.mark.redismod
4453
@skip_if_resp_version(3)
4554
def test_graph_creation(client):

0 commit comments

Comments
 (0)