Skip to content

Commit

Permalink
Suppress Graph deprecation warning in test suite (#3316)
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
kurtmckee authored and vladvildanov committed Sep 27, 2024
1 parent 00f8d6b commit c09e4d6
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 4 deletions.
3 changes: 3 additions & 0 deletions pytest.ini
Original file line number Diff line number Diff line change
Expand Up @@ -11,3 +11,6 @@ markers =
experimental: run only experimental tests
asyncio_mode = auto
timeout = 30
filterwarnings =
always
ignore:RedisGraph support is deprecated as of Redis Stack 7.2:DeprecationWarning
8 changes: 4 additions & 4 deletions tasks.py
Original file line number Diff line number Diff line change
Expand Up @@ -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"
)


Expand All @@ -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"
)


Expand Down
9 changes: 9 additions & 0 deletions tests/test_graph.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand Down

0 comments on commit c09e4d6

Please sign in to comment.