| 1 |
from pathlib import Path |
| 2 |
from minizinc import default_driver, Driver |
| 3 |
import subprocess |
| 4 |
import json |
| 5 |
|
| 6 |
|
| 7 |
def test_run_fzn(): |
| 8 |
here = Path(__file__).resolve().parent |
| 9 |
assert isinstance(default_driver, Driver) |
| 10 |
model_file = here / "test_run_fzn.fzn" |
| 11 |
p = subprocess.run( |
| 12 |
[default_driver._executable, model_file, "--json-stream"], |
| 13 |
stdin=None, |
| 14 |
stdout=subprocess.PIPE, |
| 15 |
stderr=subprocess.PIPE, |
| 16 |
) |
| 17 |
assert p.returncode == 0 |
| 18 |
messages = [json.loads(l) for l in p.stdout.splitlines(False)] |
| 19 |
assert { |
| 20 |
"type": "solution", |
| 21 |
"output": {"dzn": "x = 1;\n"}, |
| 22 |
"sections": ["dzn"], |
| 23 |
} in messages |