Skip to content

Commit b8ba391

Browse files
authored
Removing deprecated usage of forbid_global_loop=True in pytest.mark.asyncio decorator (#3542)
1 parent 8314b7f commit b8ba391

File tree

3 files changed

+10
-9
lines changed

3 files changed

+10
-9
lines changed

dev_requirements.txt

+1-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ invoke==2.2.0
44
mock
55
packaging>=20.4
66
pytest
7-
pytest-asyncio>=0.23.0,<0.24.0
7+
pytest-asyncio>=0.23.0
88
pytest-cov
99
pytest-profiling==1.8.1
1010
pytest-timeout

pyproject.toml

+1
Original file line numberDiff line numberDiff line change
@@ -88,6 +88,7 @@ markers = [
8888
"experimental: run only experimental tests",
8989
"cp_integration: credential provider integration tests",
9090
]
91+
asyncio_default_fixture_loop_scope = "function"
9192
asyncio_mode = "auto"
9293
timeout = 30
9394
filterwarnings = [

tests/test_asyncio/test_scripting.py

+8-8
Original file line numberDiff line numberDiff line change
@@ -28,14 +28,14 @@ async def r(self, create_redis):
2828
yield redis
2929
await redis.script_flush()
3030

31-
@pytest.mark.asyncio(forbid_global_loop=True)
31+
@pytest.mark.asyncio()
3232
async def test_eval(self, r):
3333
await r.flushdb()
3434
await r.set("a", 2)
3535
# 2 * 3 == 6
3636
assert await r.eval(multiply_script, 1, "a", 3) == 6
3737

38-
@pytest.mark.asyncio(forbid_global_loop=True)
38+
@pytest.mark.asyncio()
3939
@skip_if_server_version_lt("6.2.0")
4040
async def test_script_flush(self, r):
4141
await r.set("a", 2)
@@ -55,14 +55,14 @@ async def test_script_flush(self, r):
5555
await r.script_load(multiply_script)
5656
await r.script_flush("NOTREAL")
5757

58-
@pytest.mark.asyncio(forbid_global_loop=True)
58+
@pytest.mark.asyncio()
5959
async def test_evalsha(self, r):
6060
await r.set("a", 2)
6161
sha = await r.script_load(multiply_script)
6262
# 2 * 3 == 6
6363
assert await r.evalsha(sha, 1, "a", 3) == 6
6464

65-
@pytest.mark.asyncio(forbid_global_loop=True)
65+
@pytest.mark.asyncio()
6666
async def test_evalsha_script_not_loaded(self, r):
6767
await r.set("a", 2)
6868
sha = await r.script_load(multiply_script)
@@ -71,7 +71,7 @@ async def test_evalsha_script_not_loaded(self, r):
7171
with pytest.raises(exceptions.NoScriptError):
7272
await r.evalsha(sha, 1, "a", 3)
7373

74-
@pytest.mark.asyncio(forbid_global_loop=True)
74+
@pytest.mark.asyncio()
7575
async def test_script_loading(self, r):
7676
# get the sha, then clear the cache
7777
sha = await r.script_load(multiply_script)
@@ -80,7 +80,7 @@ async def test_script_loading(self, r):
8080
await r.script_load(multiply_script)
8181
assert await r.script_exists(sha) == [True]
8282

83-
@pytest.mark.asyncio(forbid_global_loop=True)
83+
@pytest.mark.asyncio()
8484
async def test_script_object(self, r):
8585
await r.script_flush()
8686
await r.set("a", 2)
@@ -97,7 +97,7 @@ async def test_script_object(self, r):
9797
# Test first evalsha block
9898
assert await multiply(keys=["a"], args=[3]) == 6
9999

100-
@pytest.mark.asyncio(forbid_global_loop=True)
100+
@pytest.mark.asyncio()
101101
async def test_script_object_in_pipeline(self, r):
102102
await r.script_flush()
103103
multiply = r.register_script(multiply_script)
@@ -127,7 +127,7 @@ async def test_script_object_in_pipeline(self, r):
127127
assert await pipe.execute() == [True, b"2", 6]
128128
assert await r.script_exists(multiply.sha) == [True]
129129

130-
@pytest.mark.asyncio(forbid_global_loop=True)
130+
@pytest.mark.asyncio()
131131
async def test_eval_msgpack_pipeline_error_in_lua(self, r):
132132
msgpack_hello = r.register_script(msgpack_hello_script)
133133
assert msgpack_hello.sha

0 commit comments

Comments
 (0)