Skip to content

Commit 9550c0d

Browse files
authored
Test qcircuit with actual PDF output (#7665)
- Change `test_qcircuit_pdf` to compile PDF file - Install LaTeX and latexmk for the CI jobs Prerequisite for tests in #7354
1 parent b1f8b82 commit 9550c0d

File tree

2 files changed

+18
-9
lines changed

2 files changed

+18
-9
lines changed

.github/workflows/ci.yml

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -99,6 +99,10 @@ jobs:
9999
with:
100100
python-version: '3.11'
101101
architecture: 'x64'
102+
- name: Install system packages
103+
run: |
104+
sudo apt-get update
105+
sudo apt-get install latexmk texlive-latex-base texlive-latex-extra
102106
- name: Install changed files test dependencies
103107
run: dev_tools/conf/pip-install-minimal-for-pytest-changed-files.sh
104108
- name: Changed files test
@@ -203,6 +207,10 @@ jobs:
203207
cache-dependency-path: |
204208
**/requirements.txt
205209
dev_tools/requirements/**/*.txt
210+
- name: Install system packages
211+
run: |
212+
sudo apt-get update
213+
sudo apt-get install latexmk texlive-latex-base texlive-latex-extra
206214
- name: Install requirements
207215
run: |
208216
pip install --upgrade setuptools wheel
@@ -263,6 +271,10 @@ jobs:
263271
cache-dependency-path: |
264272
**/requirements.txt
265273
dev_tools/requirements/**/*.txt
274+
- name: Install system packages
275+
run: |
276+
sudo apt-get update
277+
sudo apt-get install latexmk texlive-latex-base texlive-latex-extra
266278
- name: Install requirements
267279
run: |
268280
pip install --upgrade setuptools wheel

cirq-core/cirq/contrib/qcircuit/qcircuit_pdf_test.py

Lines changed: 6 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -14,18 +14,15 @@
1414

1515
from __future__ import annotations
1616

17-
from unittest import mock
18-
19-
import pylatex
17+
import pathlib
2018

2119
import cirq
2220
import cirq.contrib.qcircuit.qcircuit_pdf as qcircuit_pdf
2321

2422

25-
@mock.patch.object(pylatex.Document, "generate_pdf")
26-
def test_qcircuit_pdf(mock_generate_pdf) -> None:
23+
def test_qcircuit_pdf(tmp_path: pathlib.Path) -> None:
2724
circuit = cirq.Circuit(cirq.X(cirq.q(0)), cirq.CZ(cirq.q(0), cirq.q(1)))
28-
qcircuit_pdf.circuit_to_pdf_using_qcircuit_via_tex(circuit, "/tmp/test_file")
29-
mock_generate_pdf.assert_called_once_with(
30-
"/tmp/test_file", compiler="latexmk", compiler_args=["-pdfps"]
31-
)
25+
qcircuit_pdf.circuit_to_pdf_using_qcircuit_via_tex(circuit, f"{tmp_path}/test_file")
26+
assert (tmp_path / "test_file.pdf").is_file()
27+
assert not (tmp_path / "test_file.dvi").exists()
28+
assert not (tmp_path / "test_file.ps").exists()

0 commit comments

Comments
 (0)