Coverage for tests/test_generation/exhaustive/conftest.py: 100%
23 statements
« prev ^ index » next coverage.py v7.2.7, created at 2024-08-27 18:25 +0000
« prev ^ index » next coverage.py v7.2.7, created at 2024-08-27 18:25 +0000
1import shutil
2from pathlib import Path
4import pytest
6from prisma.cli import prisma
7from prisma.utils import DEBUG_GENERATOR
8from prisma.cli.utils import maybe_exit
10from .utils import ROOTDIR
13def remove_generated_clients() -> None:
14 output = ROOTDIR.joinpath('__prisma_sync_output__')
15 if output.exists():
16 shutil.rmtree(str(output))
18 output = ROOTDIR.joinpath('__prisma_async_output__')
19 if output.exists():
20 shutil.rmtree(str(output))
23def pytest_sessionfinish(session: pytest.Session) -> None:
24 if not DEBUG_GENERATOR: # pragma: no branch
25 remove_generated_clients()
28@pytest.fixture(autouse=True, scope='session')
29def generate_clients() -> None:
30 """Generate the clients required to run these tests"""
31 remove_generated_clients()
32 base = Path(__file__).parent
33 for schema in ['sync.schema.prisma', 'async.schema.prisma']:
34 maybe_exit(prisma.run(['generate', f'--schema={base.joinpath(schema)}']))