codegen / assets /train /deepcoder_primeintellect /deepcoder_primeintellect_0bdff1e29140bf72 /test_solution.py
| import subprocess | |
| import sys | |
| from pathlib import Path | |
| cases = [{'input': '7 4\n1 2\n1 3\n1 4\n3 5\n3 6\n4 7\n', 'output': '7'}, {'input': '4 1\n1 2\n1 3\n2 4\n', 'output': '2'}, {'input': '8 5\n7 5\n1 7\n6 1\n3 7\n8 3\n2 1\n4 5\n', 'output': '9'}, {'input': '2 1\n1 2\n', 'output': '1'}, {'input': '20 7\n9 7\n3 7\n15 9\n1 3\n11 9\n18 7\n17 18\n20 1\n4 11\n2 11\n12 18\n8 18\n13 2\n19 2\n10 9\n6 13\n5 8\n14 1\n16 13\n', 'output': '38'}, {'input': '3 2\n1 2\n1 3\n', 'output': '2'}, {'input': '3 1\n1 2\n2 3\n', 'output': '2'}] | |
| solution = Path(__file__).with_name("solution.py") | |
| for index, case in enumerate(cases): | |
| proc = subprocess.run( | |
| [sys.executable, str(solution)], | |
| input=case["input"], | |
| text=True, | |
| stdout=subprocess.PIPE, | |
| stderr=subprocess.PIPE, | |
| timeout=10, | |
| ) | |
| if proc.returncode != 0: | |
| raise AssertionError(f"case {index} exited {proc.returncode}: {proc.stderr}") | |
| got = proc.stdout.strip() | |
| expected = case["output"].strip() | |
| if got.split() != expected.split(): | |
| raise AssertionError( | |
| f"case {index} output mismatch\nexpected={expected!r}\ngot={got!r}\nstderr={proc.stderr}" | |
| ) | |
| print('deepcoder_primeintellect_io') | |