Skip to content

Commit

Permalink
test: Print hugr-cli's errors on python tests (#1310)
Browse files Browse the repository at this point in the history
Prints the error returned by `hugr-cli` when something fails, so we get
better feedback.

Before:
```
subprocess.CalledProcessError: Command '['/Users/agustinborgna/src/hugr/target/debug/hugr', '-']' returned non-zero exit status 1.
```

After:
```
RuntimeError: Error validating HUGR: Parent node Node(0) has extensions [] that are too restrictive for child node Node(5), they must include child extensions [IdentList("quantum.tket2")]
```
  • Loading branch information
aborgna-q authored Jul 16, 2024
1 parent cb84b84 commit afe1a77
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion hugr-py/tests/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,11 @@ def validate(h: Hugr, mermaid: bool = False, roundtrip: bool = True):
if mermaid:
cmd.append("--mermaid")
serial = h.to_serial().to_json()
subprocess.run(cmd, check=True, input=serial.encode()) # noqa: S603
try:
subprocess.run(cmd, check=True, input=serial.encode(), capture_output=True) # noqa: S603
except subprocess.CalledProcessError as e:
error = e.stderr.decode()
raise RuntimeError(error) from e

if roundtrip:
h2 = Hugr.from_serial(SerialHugr.load_json(json.loads(serial)))
Expand Down

0 comments on commit afe1a77

Please sign in to comment.