File size: 714 Bytes
ab98ae3
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
import os
import pathlib
import subprocess
import sys

ROOT = pathlib.Path(__file__).parent.parent


def test_generated_code_matches_api_definition(tmp_path):
    out = tmp_path / "generated"
    env = {**os.environ, "PATH": f"{pathlib.Path(sys.executable).parent}{os.pathsep}{os.environ['PATH']}"}
    subprocess.run([ROOT / "scripts" / "generate.sh", out], check=True, env=env, capture_output=True)

    committed = ROOT / "generated"
    for fresh in out.iterdir():
        assert (committed / fresh.name).read_text() == fresh.read_text(), (
            f"generated/{fresh.name} is stale; run scripts/generate.sh"
        )
    assert {p.name for p in out.iterdir()} == {p.name for p in committed.glob("*.py")}