| 1 |
from pathlib import Path |
| 2 |
import subprocess |
| 3 |
import json |
| 4 |
|
| 5 |
|
| 6 |
def test_array_dzn_output(): |
| 7 |
from minizinc import default_driver, Driver |
| 8 |
|
| 9 |
expected = { |
| 10 |
"type": "solution", |
| 11 |
"output": {"dzn": "y = array3d('a b'..'a b', 'a b'..'a b', c..c, [1]);\n"}, |
| 12 |
"sections": ["dzn"], |
| 13 |
} |
| 14 |
|
| 15 |
here = Path(__file__).resolve().parent |
| 16 |
assert isinstance(default_driver, Driver) |
| 17 |
model_file = here / "test_array_dzn_output.mzn" |
| 18 |
|
| 19 |
p = subprocess.run( |
| 20 |
[ |
| 21 |
default_driver._executable, |
| 22 |
model_file, |
| 23 |
"--json-stream", |
| 24 |
"--solver", |
| 25 |
"gecode", |
| 26 |
], |
| 27 |
stdin=None, |
| 28 |
stdout=subprocess.PIPE, |
| 29 |
stderr=subprocess.PIPE, |
| 30 |
) |
| 31 |
assert p.returncode == 0 |
| 32 |
actual = [json.loads(l) for l in p.stdout.splitlines(False)] |
| 33 |
assert expected in actual |