From 4d29f789ba7519f83869b5e541bb83761e857e68 Mon Sep 17 00:00:00 2001 From: Pavol Juhas Date: Wed, 24 Sep 2025 12:22:37 -0700 Subject: [PATCH 1/2] Change test_qcircuit_pdf to compile PDF file --- .../cirq/contrib/qcircuit/qcircuit_pdf_test.py | 15 ++++++--------- 1 file changed, 6 insertions(+), 9 deletions(-) diff --git a/cirq-core/cirq/contrib/qcircuit/qcircuit_pdf_test.py b/cirq-core/cirq/contrib/qcircuit/qcircuit_pdf_test.py index 5c4f656647e..86719f248cc 100644 --- a/cirq-core/cirq/contrib/qcircuit/qcircuit_pdf_test.py +++ b/cirq-core/cirq/contrib/qcircuit/qcircuit_pdf_test.py @@ -14,18 +14,15 @@ from __future__ import annotations -from unittest import mock - -import pylatex +import pathlib import cirq import cirq.contrib.qcircuit.qcircuit_pdf as qcircuit_pdf -@mock.patch.object(pylatex.Document, "generate_pdf") -def test_qcircuit_pdf(mock_generate_pdf) -> None: +def test_qcircuit_pdf(tmp_path: pathlib.Path) -> None: circuit = cirq.Circuit(cirq.X(cirq.q(0)), cirq.CZ(cirq.q(0), cirq.q(1))) - qcircuit_pdf.circuit_to_pdf_using_qcircuit_via_tex(circuit, "/tmp/test_file") - mock_generate_pdf.assert_called_once_with( - "/tmp/test_file", compiler="latexmk", compiler_args=["-pdfps"] - ) + qcircuit_pdf.circuit_to_pdf_using_qcircuit_via_tex(circuit, f"{tmp_path}/test_file") + assert (tmp_path / "test_file.pdf").is_file() + assert not (tmp_path / "test_file.dvi").exists() + assert not (tmp_path / "test_file.ps").exists() From f66e2692954012feb545e421787749f8ae83a4e0 Mon Sep 17 00:00:00 2001 From: Pavol Juhas Date: Wed, 24 Sep 2025 12:23:49 -0700 Subject: [PATCH 2/2] Install LaTeX and latexmk for the CI jobs --- .github/workflows/ci.yml | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index fd90b65bfa6..61debca22ef 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -99,6 +99,10 @@ jobs: with: python-version: '3.11' architecture: 'x64' + - name: Install system packages + run: | + sudo apt-get update + sudo apt-get install latexmk texlive-latex-base texlive-latex-extra - name: Install changed files test dependencies run: dev_tools/conf/pip-install-minimal-for-pytest-changed-files.sh - name: Changed files test @@ -203,6 +207,10 @@ jobs: cache-dependency-path: | **/requirements.txt dev_tools/requirements/**/*.txt + - name: Install system packages + run: | + sudo apt-get update + sudo apt-get install latexmk texlive-latex-base texlive-latex-extra - name: Install requirements run: | pip install --upgrade setuptools wheel @@ -263,6 +271,10 @@ jobs: cache-dependency-path: | **/requirements.txt dev_tools/requirements/**/*.txt + - name: Install system packages + run: | + sudo apt-get update + sudo apt-get install latexmk texlive-latex-base texlive-latex-extra - name: Install requirements run: | pip install --upgrade setuptools wheel