(
*,
strategy_id: str = "example",
surfaces: tuple[str, ...] = (),
drop: tuple[str | None, str] | None = None,
duplicate: tuple[str | None, str] | None = None,
incompatible: tuple[str | None, str] | None = None,
)
| 27 | |
| 28 | |
| 29 | def _strategy_source( |
| 30 | *, |
| 31 | strategy_id: str = "example", |
| 32 | surfaces: tuple[str, ...] = (), |
| 33 | drop: tuple[str | None, str] | None = None, |
| 34 | duplicate: tuple[str | None, str] | None = None, |
| 35 | incompatible: tuple[str | None, str] | None = None, |
| 36 | ) -> str: |
| 37 | cells: Final = tuple( |
| 38 | (surface, function) |
| 39 | for surface in (surfaces or (None,)) |
| 40 | for function in SDK_FUNCTIONS |
| 41 | if (surface, function) != drop |
| 42 | ) |
| 43 | definitions: Final = tuple( |
| 44 | ( |
| 45 | f"strategy.CaseDefinition({function!r}, " |
| 46 | "strategy.ModuleCaseSpec(coverage=models.Coverage.COMPLETE, module='tests.example'), " |
| 47 | f"surface={surface!r})" |
| 48 | if (surface, function) == incompatible |
| 49 | else ( |
| 50 | f"strategy.CaseDefinition({function!r}, " |
| 51 | "strategy.NotImplementedCaseSpec(reason='Not implemented yet'), " |
| 52 | f"surface={surface!r})" |
| 53 | ) |
| 54 | ) |
| 55 | for surface, function in (*cells, *((duplicate,) if duplicate is not None else ())) |
| 56 | ) |
| 57 | return ( |
| 58 | "import importlib\n" |
| 59 | "from pathlib import Path\n" |
| 60 | "strategy = importlib.import_module('tests.rust-python-harness.shared.reporting.strategy')\n" |
| 61 | "models = importlib.import_module('tests.rust-python-harness.shared.reporting.models')\n" |
| 62 | "runner = importlib.import_module('tests.rust-python-harness.strategies.trace_parity.runner')\n" |
| 63 | "rendering = importlib.import_module('tests.rust-python-harness.shared.reporting.rendering')\n" |
| 64 | "def render(results):\n" |
| 65 | " return (rendering.ReportSection('Example outcomes', " |
| 66 | "tuple(rendering.render_case_outcome(r) for r in results)),)\n" |
| 67 | f"CASES = ({','.join(definitions)},)\n" |
| 68 | "STRATEGY = strategy.StrategyDefinition(" |
| 69 | f"id={strategy_id!r}, order=1, label='Example strategy', description='Example description', " |
| 70 | "directory=Path(__file__).parent, runnable_spec=strategy.SuiteCaseSpec, cases=CASES, " |
| 71 | f"run=runner.run_trace_cases, render=render, surfaces={surfaces!r})\n" |
| 72 | ) |
| 73 | |
| 74 | |
| 75 | def _write_strategy_folder( |
no test coverage detected