Skip to content

Commit fec68ae

Browse files
authored
Fix ci-daily pytest failure (#6335)
* Fix requirements installation for Windows * Run notebook tests only on Linux platform * Run test_isolated_packages on POSIX platforms only Temporary workaround for #6336
1 parent 34e8dab commit fec68ae

14 files changed

+36
-4
lines changed

.github/workflows/ci-daily.yml

+3-4
Original file line numberDiff line numberDiff line change
@@ -58,10 +58,9 @@ jobs:
5858
- name: Install requirements
5959
run: |
6060
pip install --pre cirq &&
61-
pip install \
62-
-r dev_tools/requirements/deps/format.txt \
63-
-r dev_tools/requirements/deps/pylint.txt \
64-
-r dev_tools/requirements/deps/pytest.txt
61+
pip install -r dev_tools/requirements/deps/format.txt &&
62+
pip install -r dev_tools/requirements/deps/pylint.txt &&
63+
pip install -r dev_tools/requirements/deps/pytest.txt
6564
- name: Pytest Windows
6665
run: check/pytest -n auto --ignore=cirq-core/cirq/contrib --enable-slow-tests
6766
shell: bash

cirq-ft/cirq_ft/algos/and_gate_test.py

+2
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414

1515
import itertools
1616
import random
17+
import sys
1718
from typing import List, Tuple
1819

1920
import cirq
@@ -203,6 +204,7 @@ def test_and_gate_adjoint(cv: Tuple[int, int]):
203204
cirq_ft.testing.assert_circuit_inp_out_cirqsim(circuit, [c1, c2, t], inp, out)
204205

205206

207+
@pytest.mark.skipif(sys.platform != "linux", reason="Linux-only test")
206208
def test_notebook():
207209
execute_notebook('and_gate')
208210

cirq-ft/cirq_ft/algos/apply_gate_to_lth_target_test.py

+3
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,8 @@
1212
# See the License for the specific language governing permissions and
1313
# limitations under the License.
1414

15+
import sys
16+
1517
import cirq
1618
import cirq_ft
1719
import pytest
@@ -101,5 +103,6 @@ def test_apply_gate_to_lth_qubit_make_on():
101103
assert op.gate.control_regs == op2.gate.control_regs
102104

103105

106+
@pytest.mark.skipif(sys.platform != "linux", reason="Linux-only test")
104107
def test_notebook():
105108
execute_notebook('apply_gate_to_lth_target')

cirq-ft/cirq_ft/algos/generic_select_test.py

+3
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,8 @@
1111
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1212
# See the License for the specific language governing permissions and
1313
# limitations under the License.
14+
15+
import sys
1416
from typing import List, Sequence
1517

1618
import cirq
@@ -276,5 +278,6 @@ def test_generic_select_consistent_protocols_and_controlled():
276278
_ = gate.controlled(num_controls=2)
277279

278280

281+
@pytest.mark.skipif(sys.platform != "linux", reason="Linux-only test")
279282
def test_notebook():
280283
execute_notebook('generic_select')

cirq-ft/cirq_ft/algos/hubbard_model_test.py

+3
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,8 @@
1212
# See the License for the specific language governing permissions and
1313
# limitations under the License.
1414

15+
import sys
16+
1517
import cirq
1618
import cirq_ft
1719
import pytest
@@ -72,5 +74,6 @@ def test_hubbard_model_consistent_protocols():
7274
assert cirq.circuit_diagram_info(select_gate).wire_symbols == tuple(expected_symbols)
7375

7476

77+
@pytest.mark.skipif(sys.platform != "linux", reason="Linux-only test")
7578
def test_notebook():
7679
execute_notebook('hubbard_model')

cirq-ft/cirq_ft/algos/qrom_test.py

+2
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
# limitations under the License.
1414

1515
import itertools
16+
import sys
1617

1718
import cirq
1819
import cirq_ft
@@ -114,6 +115,7 @@ def test_qrom_repr():
114115
cirq.testing.assert_equivalent_repr(qrom, setup_code="import cirq_ft\nimport numpy as np")
115116

116117

118+
@pytest.mark.skipif(sys.platform != "linux", reason="Linux-only test")
117119
def test_notebook():
118120
execute_notebook('qrom')
119121

cirq-ft/cirq_ft/algos/qubitization_walk_operator_test.py

+3
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,8 @@
1212
# See the License for the specific language governing permissions and
1313
# limitations under the License.
1414

15+
import sys
16+
1517
import cirq
1618
import cirq_ft
1719
import numpy as np
@@ -240,6 +242,7 @@ def test_qubitization_walk_operator_consistent_protocols_and_controlled():
240242
_ = gate.controlled(num_controls=2)
241243

242244

245+
@pytest.mark.skipif(sys.platform != "linux", reason="Linux-only test")
243246
def test_notebook():
244247
execute_notebook('qubitization_walk_operator')
245248
execute_notebook('phase_estimation_of_quantum_walk')

cirq-ft/cirq_ft/algos/state_preparation_test.py

+3
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,8 @@
1212
# See the License for the specific language governing permissions and
1313
# limitations under the License.
1414

15+
import sys
16+
1517
import cirq
1618
import cirq_ft
1719
import numpy as np
@@ -93,5 +95,6 @@ def test_state_preparation_via_coherent_alias_sampling_diagram():
9395
)
9496

9597

98+
@pytest.mark.skipif(sys.platform != "linux", reason="Linux-only test")
9699
def test_notebook():
97100
execute_notebook('state_preparation')

cirq-ft/cirq_ft/algos/swap_network_test.py

+2
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
# limitations under the License.
1414

1515
import random
16+
import sys
1617

1718
import cirq
1819
import cirq_ft
@@ -146,6 +147,7 @@ def test_multi_target_cswap_make_on():
146147
assert cswap1 == cswap2
147148

148149

150+
@pytest.mark.skipif(sys.platform != "linux", reason="Linux-only test")
149151
def test_notebook():
150152
execute_notebook('swap_network')
151153

cirq-ft/cirq_ft/algos/unary_iteration_gate_test.py

+2
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
# limitations under the License.
1414

1515
import itertools
16+
import sys
1617
from typing import Sequence, Tuple
1718

1819
import cirq
@@ -198,5 +199,6 @@ def test_unary_iteration_loop_empty_range():
198199
assert list(cirq_ft.unary_iteration(4, 3, [], [], [cirq.q('s')], qm)) == []
199200

200201

202+
@pytest.mark.skipif(sys.platform != "linux", reason="Linux-only test")
201203
def test_notebook():
202204
execute_notebook('unary_iteration')

cirq-ft/cirq_ft/infra/gate_with_registers_test.py

+3
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,8 @@
1212
# See the License for the specific language governing permissions and
1313
# limitations under the License.
1414

15+
import sys
16+
1517
import cirq
1618
import cirq_ft
1719
import numpy as np
@@ -169,5 +171,6 @@ def test_gate_with_registers():
169171
assert op1 == op2
170172

171173

174+
@pytest.mark.skipif(sys.platform != "linux", reason="Linux-only test")
172175
def test_notebook():
173176
execute_notebook('gate_with_registers')

cirq-ft/cirq_ft/infra/t_complexity_protocol_test.py

+3
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,8 @@
1212
# See the License for the specific language governing permissions and
1313
# limitations under the License.
1414

15+
import sys
16+
1517
import cirq
1618
import cirq_ft
1719
import pytest
@@ -207,5 +209,6 @@ def gate(self):
207209
cirq_ft.t_complexity.cache_clear()
208210

209211

212+
@pytest.mark.skipif(sys.platform != "linux", reason="Linux-only test")
210213
def test_notebook():
211214
execute_notebook('t_complexity')

dev_tools/notebooks/notebook_test.py

+2
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121

2222
import importlib.metadata
2323
import os
24+
import sys
2425
import tempfile
2526

2627
import pytest
@@ -86,6 +87,7 @@ def env_with_temporary_pip_target():
8687

8788

8889
@pytest.mark.slow
90+
@pytest.mark.skipif(sys.platform != "linux", reason="Linux-only test")
8991
@pytest.mark.parametrize("notebook_path", filter_notebooks(list_all_notebooks(), SKIP_NOTEBOOKS))
9092
def test_notebooks_against_cirq_head(
9193
notebook_path, require_packages_not_changed, env_with_temporary_pip_target

dev_tools/packaging/isolated_packages_test.py

+2
Original file line numberDiff line numberDiff line change
@@ -21,10 +21,12 @@
2121

2222
from dev_tools import shell_tools
2323
from dev_tools.modules import list_modules
24+
from dev_tools.test_utils import only_on_posix
2425

2526
PACKAGES = ["-r", "dev_tools/requirements/isolated-base.env.txt"]
2627

2728

29+
@only_on_posix
2830
@pytest.mark.slow
2931
# ensure that no cirq packages are on the PYTHONPATH, this is important, otherwise
3032
# the "isolation" fails and for example cirq-core would be on the PATH

0 commit comments

Comments
 (0)