Skip to content

Commit 4be160f

Browse files
authored
Use @pytest_asyncio.fixture instead of @pytest.fixture for async fixtures (#3025)
1 parent 7b24842 commit 4be160f

37 files changed

+81
-44
lines changed

mars/conftest.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818

1919
import psutil
2020
import pytest
21+
import pytest_asyncio
2122

2223
from mars.config import option_context
2324
from mars.core.mode import is_kernel_mode, is_build_mode
@@ -132,7 +133,7 @@ def stop_ray(request): # pragma: no cover
132133
ray.shutdown()
133134

134135

135-
@pytest.fixture
136+
@pytest_asyncio.fixture
136137
async def ray_create_mars_cluster(request):
137138
from mars.deploy.oscar.ray import new_cluster, _load_config
138139

mars/dataframe/contrib/raydataset/tests/test_raydataset.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
import numpy as np
1717
import pandas as pd
1818
import pytest
19+
import pytest_asyncio
1920

2021
from ..... import dataframe as md
2122
from .....deploy.oscar.ray import new_cluster
@@ -39,7 +40,7 @@
3940
sklearn = None
4041

4142

42-
@pytest.fixture
43+
@pytest_asyncio.fixture
4344
async def create_cluster(request):
4445
client = await new_cluster(
4546
supervisor_mem=256 * 1024**2,

mars/deploy/oscar/tests/test_fault_injection.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414

1515
import os
1616
import pytest
17+
import pytest_asyncio
1718
import traceback
1819
import numpy as np
1920
import pandas as pd
@@ -40,7 +41,7 @@
4041
)
4142

4243

43-
@pytest.fixture
44+
@pytest_asyncio.fixture
4445
async def fault_cluster(request):
4546
param = getattr(request, "param", {})
4647
start_method = os.environ.get("POOL_START_METHOD", None)

mars/deploy/oscar/tests/test_local.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@
2323
import numpy as np
2424
import pandas as pd
2525
import pytest
26+
import pytest_asyncio
2627

2728
try:
2829
import vineyard
@@ -103,7 +104,7 @@
103104

104105

105106
@pytest.mark.parametrize(indirect=True)
106-
@pytest.fixture(params=params)
107+
@pytest_asyncio.fixture(params=params)
107108
async def create_cluster(request):
108109
if request.param == "default":
109110
config = CONFIG_TEST_FILE
@@ -822,7 +823,7 @@ async def _exec():
822823
min_task_runtime = 2
823824

824825

825-
@pytest.fixture
826+
@pytest_asyncio.fixture
826827
async def speculative_cluster():
827828
config = _load_config()
828829
config["scheduling"]["speculation"]["enabled"] = True

mars/deploy/oscar/tests/test_ray.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@
2424
import numpy as np
2525
import pandas as pd
2626
import pytest
27+
import pytest_asyncio
2728

2829
import mars
2930
from .... import oscar as mo
@@ -90,7 +91,7 @@
9091
EXPECT_PROFILING_STRUCTURE_NO_SLOW["supervisor"]["slow_subtasks"] = {}
9192

9293

93-
@pytest.fixture
94+
@pytest_asyncio.fixture
9495
async def create_cluster(request):
9596
param = getattr(request, "param", {})
9697
ray_config = _load_config(CONFIG_FILE)

mars/deploy/oscar/tests/test_ray_fault_injection.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
import os
1616

1717
import pytest
18+
import pytest_asyncio
1819

1920
from ....oscar.errors import ServerClosed
2021
from ....services.tests.fault_injection_manager import (
@@ -45,7 +46,7 @@
4546
}
4647

4748

48-
@pytest.fixture
49+
@pytest_asyncio.fixture
4950
async def fault_cluster(request):
5051
param = getattr(request, "param", {})
5152
ray_config = _load_config(RAY_CONFIG_FILE)

mars/deploy/oscar/tests/test_ray_scheduling.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
# limitations under the License.
1414

1515
import pytest
16+
import pytest_asyncio
1617

1718
from ....tests.core import require_ray
1819
from ....utils import lazy_import
@@ -26,7 +27,7 @@
2627
ray = lazy_import("ray")
2728

2829

29-
@pytest.fixture
30+
@pytest_asyncio.fixture
3031
async def speculative_cluster():
3132
client = await new_cluster(
3233
"test_cluster",

mars/oscar/backends/mars/tests/test_debug.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121
from typing import List
2222

2323
import pytest
24+
import pytest_asyncio
2425

2526
from ..... import oscar as mo
2627
from ....debug import reload_debug_opts_from_env, get_debug_options
@@ -62,7 +63,7 @@ async def call_self_ref(self):
6263
await self.ref().wait(1)
6364

6465

65-
@pytest.fixture
66+
@pytest_asyncio.fixture
6667
async def actor_pool():
6768
start_method = (
6869
os.environ.get("POOL_START_METHOD", "forkserver")

mars/oscar/backends/mars/tests/test_mars_actor_context.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222

2323
import pandas as pd
2424
import pytest
25+
import pytest_asyncio
2526

2627
from ..... import oscar as mo
2728
from .....oscar.core import ActorRef, LocalActorRef
@@ -241,7 +242,7 @@ def get_call_log(self):
241242

242243

243244
@pytest.mark.parametrize(indirect=True)
244-
@pytest.fixture(params=[False, True])
245+
@pytest_asyncio.fixture(params=[False, True])
245246
async def actor_pool(request):
246247
start_method = (
247248
os.environ.get("POOL_START_METHOD", "forkserver")

mars/oscar/backends/ray/tests/test_ray_actor_context.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
import time
1717

1818
import pytest
19+
import pytest_asyncio
1920

2021
from .....utils import lazy_import
2122
from .....tests.core import require_ray
@@ -29,7 +30,7 @@
2930
ray = lazy_import("ray")
3031

3132

32-
@pytest.fixture
33+
@pytest_asyncio.fixture
3334
async def actor_pool_context():
3435
pg_name, n_process = f"ray_cluster_{time.time_ns()}", 2
3536
from .....serialization.ray import (

0 commit comments

Comments
 (0)