Skip to content

Commit 747f7e1

Browse files
Prevent getting test snapshot updates getting stuck
1 parent cff5364 commit 747f7e1

File tree

1 file changed

+10
-5
lines changed

1 file changed

+10
-5
lines changed

tests/codegen/test_rpc.py

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import asyncio
22
import importlib
3+
import os
34
import shutil
45
from datetime import timedelta
56
from pathlib import Path
@@ -19,7 +20,8 @@
1920

2021
@pytest.fixture(scope="session", autouse=True)
2122
def generate_rpc_client() -> None:
22-
shutil.rmtree("tests/codegen/rpc/generated")
23+
shutil.rmtree("tests/codegen/rpc/generated", ignore_errors=True)
24+
os.makedirs("tests/codegen/rpc/generated")
2325

2426
def file_opener(path: Path) -> TextIO:
2527
return open(path, "w")
@@ -35,11 +37,16 @@ def file_opener(path: Path) -> TextIO:
3537
)
3638

3739

40+
@pytest.fixture(scope="session", autouse=True)
41+
def reload_rpc_import(generate_rpc_client: None) -> None:
42+
import tests.codegen.rpc.generated
43+
44+
importlib.reload(tests.codegen.rpc.generated)
45+
46+
3847
@pytest.mark.asyncio
3948
@pytest.mark.parametrize("handlers", [{**basic_rpc_method}])
4049
async def test_basic_rpc(client: Client) -> None:
41-
import tests.codegen.rpc.generated
42-
importlib.reload(tests.codegen.rpc.generated)
4350
from tests.codegen.rpc.generated import RpcClient
4451

4552
res = await RpcClient(client).test_service.rpc_method(
@@ -69,8 +76,6 @@ async def rpc_timeout_handler(request: str, context: grpc.aio.ServicerContext) -
6976
@pytest.mark.asyncio
7077
@pytest.mark.parametrize("handlers", [{**rpc_timeout_method}])
7178
async def test_rpc_timeout(client: Client) -> None:
72-
import tests.codegen.rpc.generated
73-
importlib.reload(tests.codegen.rpc.generated)
7479
from tests.codegen.rpc.generated import RpcClient
7580

7681
with pytest.raises(RiverException):

0 commit comments

Comments
 (0)