Debian Codegraph @

tests/spec/unit/driver/test_command_line_error.py

raw
1 from pathlib import Path
2 from minizinc import default_driver, Driver
3 import subprocess
4 import json
5
6
7 def test_command_line_error():
8 assert isinstance(default_driver, Driver)
9 p = subprocess.run(
10 [default_driver._executable, "--made-up-argument", "--json-stream"],
11 stdin=None,
12 stdout=subprocess.PIPE,
13 stderr=subprocess.PIPE,
14 )
15 assert p.returncode == 1
16 messages = [json.loads(l) for l in p.stdout.splitlines(False)]
17 errors = [m for m in messages if m["type"] == "error"]
18 assert len(errors) == 1
19 assert errors[0]["what"] == "argument parsing error"