Skip to content

Commit

Permalink
Only codegen for tests once per pytest invocation
Browse files Browse the repository at this point in the history
  • Loading branch information
blast-hardcheese committed Nov 29, 2024
1 parent 34194df commit 0aeaf33
Showing 1 changed file with 11 additions and 3 deletions.
14 changes: 11 additions & 3 deletions tests/codegen/test_rpc.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,21 +3,29 @@

import pytest

import importlib
from replit_river.client import Client
from replit_river.codegen.client import schema_to_river_client_codegen
from tests.common_handlers import basic_rpc_method


@pytest.mark.asyncio
@pytest.mark.parametrize("handlers", [{**basic_rpc_method}])
async def test_basic_rpc(client: Client) -> None:
@pytest.fixture(scope="session", autouse=True)
def generate_rpc_client() -> None:
import tests.codegen.rpc.generated

shutil.rmtree("tests/codegen/rpc/generated")
schema_to_river_client_codegen(
"tests/codegen/rpc/schema.json",
"tests/codegen/rpc/generated",
"RpcClient",
True,
)
importlib.reload(tests.codegen.rpc.generated)


@pytest.mark.asyncio
@pytest.mark.parametrize("handlers", [{**basic_rpc_method}])
async def test_basic_rpc(client: Client) -> None:
from tests.codegen.rpc.generated import RpcClient

res = await RpcClient(client).test_service.rpc_method(
Expand Down

0 comments on commit 0aeaf33

Please sign in to comment.