import subprocess import sys from pathlib import Path cases = [{'input': '6\n', 'output': 'six\n'}, {'input': '99\n', 'output': 'ninety-nine\n'}, {'input': '20\n', 'output': 'twenty\n'}, {'input': '10\n', 'output': 'ten\n'}, {'input': '15\n', 'output': 'fifteen\n'}, {'input': '27\n', 'output': 'twenty-seven\n'}, {'input': '40\n', 'output': 'forty\n'}, {'input': '63\n', 'output': 'sixty-three\n'}, {'input': '0\n', 'output': 'zero\n'}, {'input': '1\n', 'output': 'one\n'}, {'input': '2\n', 'output': 'two\n'}, {'input': '8\n', 'output': 'eight\n'}, {'input': '9\n', 'output': 'nine\n'}, {'input': '11\n', 'output': 'eleven\n'}, {'input': '12\n', 'output': 'twelve\n'}, {'input': '13\n', 'output': 'thirteen\n'}, {'input': '14\n', 'output': 'fourteen\n'}, {'input': '16\n', 'output': 'sixteen\n'}, {'input': '17\n', 'output': 'seventeen\n'}, {'input': '18\n', 'output': 'eighteen\n'}] 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')