Skip to content

Commit 2425563

Browse files
committed
Add matrix tests for Qiskit
1 parent e187227 commit 2425563

File tree

7 files changed

+50
-10
lines changed

7 files changed

+50
-10
lines changed

.ado/ci.yml

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -60,18 +60,24 @@ jobs:
6060
displayName: Set Python version
6161

6262
- script: |
63-
pip install pytest pytest-azurepipelines pytest-cov pytest-xdist
64-
displayName: Install pytest dependencies
63+
python -m pip install --upgrade pip
64+
pip install pytest pytest-azurepipelines pytest-cov pytest-xdist tox
65+
displayName: Install test dependencies
6566
6667
- script: |
6768
pip freeze
6869
displayName: List installed packages
6970
7071
- script: |
7172
cd $(Build.SourcesDirectory)/azure-quantum
72-
pip install .[qiskit,cirq,qsharp,dev]
73-
pytest --numprocesses $(PYTEST_MAX_PARALLEL_TESTS) --cov-report term --cov=azure.quantum --junitxml test-output-azure-quantum.xml $(Build.SourcesDirectory)/azure-quantum
73+
pip install .[cirq,qsharp,dev]
74+
pytest --numprocesses $(PYTEST_MAX_PARALLEL_TESTS) --cov-report term --cov=azure.quantum --junitxml test-output-azure-quantum.xml --ignore tests/unit/test_qiskit.py
7475
displayName: Run azure-quantum unit tests
76+
77+
- script: |
78+
cd $(Build.SourcesDirectory)/azure-quantum
79+
tox -e py311-qiskit1,py311-qiskit2
80+
displayName: Run Qiskit matrix tests
7581
7682
- task: PublishTestResults@2
7783
displayName: 'Publish tests results (python)'

.ado/publish.yml

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -110,19 +110,25 @@ extends:
110110
displayName: Set Python version
111111

112112
- script: |
113-
pip install pytest pytest-azurepipelines pytest-cov pytest-xdist
114-
displayName: Install pytest dependencies
113+
python -m pip install --upgrade pip
114+
pip install pytest pytest-azurepipelines pytest-cov pytest-xdist tox
115+
displayName: Install test dependencies
115116
116117
- script: |
117118
pip freeze
118119
displayName: List installed packages
119120
120121
- script: |
121122
cd $(Build.SourcesDirectory)/azure-quantum
122-
pip install .[qiskit,cirq,qsharp,dev]
123-
pytest --numprocesses $(PYTEST_MAX_PARALLEL_TESTS) --cov-report term --cov=azure.quantum --junitxml test-output-azure-quantum.xml $(Build.SourcesDirectory)/azure-quantum
123+
pip install .[cirq,qsharp,dev]
124+
pytest --numprocesses $(PYTEST_MAX_PARALLEL_TESTS) --cov-report term --cov=azure.quantum --junitxml test-output-azure-quantum.xml --ignore tests/unit/test_qiskit.py $(Build.SourcesDirectory)/azure-quantum
124125
displayName: Run Unit-tests
125126
127+
- script: |
128+
cd $(Build.SourcesDirectory)/azure-quantum
129+
tox -e py311-qiskit1,py311-qiskit2
130+
displayName: Run Qiskit matrix tests
131+
126132
- task: PublishTestResults@2
127133
displayName: 'Publish test results (python)'
128134
condition: succeededOrFailed()

.gitignore

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -391,7 +391,6 @@ coverage.xml
391391
htmlcov/
392392

393393
# Other
394-
*.ini
395394
dist/
396395
temp/
397396
.[v]env/

azure-quantum/requirements-dev.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,3 +3,4 @@ pytest-xdist>=3.8.0,<4.0
33
vcrpy>=4.3.1 # fixes https://github.com/kevin1024/vcrpy/issues/688
44
azure-devtools>=1.2.0,<2.0
55
graphviz>=0.20.1
6+
tox>=4.32.0
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
1-
qsharp[qiskit]>=1.9.0,<2.0
1+
qsharp[qiskit]>=1.22.0,<2.0
22
Markdown>=3.4.1,<4.0
33
python-markdown-math>=0.8.0,<1.0

azure-quantum/tests/README.md

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -133,6 +133,17 @@ Example:
133133
pytest -k test_job_refresh
134134
```
135135

136+
### Qiskit multi-version matrix
137+
138+
To replay the recorded Qiskit tests against both supported majors, run the tox environments from the `azure-quantum` directory using `tox -e py{310,311,312,313}-qiskit{1,2}`, for example:
139+
140+
```bash
141+
tox -e py311-qiskit1
142+
tox -e py311-qiskit2
143+
```
144+
145+
Each command provisions an isolated virtual environment with the correct Qiskit version and executes `tests/unit/test_qiskit.py`.
146+
136147
## E2E Live Test Pipeline
137148

138149
We have a private E2E test pipeline that run all the tests against

azure-quantum/tox.ini

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
[tox]
2+
envlist = py{310,311,312,313}-qiskit{1,2}
3+
skipsdist = true
4+
5+
[testenv]
6+
basepython =
7+
py310: python3.10
8+
py311: python3.11
9+
py312: python3.12
10+
py313: python3.13
11+
allowlist_externals = pytest
12+
deps =
13+
qiskit1: qiskit<2
14+
qiskit2: qiskit>=2,<3
15+
-e .[qiskit]
16+
-r requirements-dev.txt
17+
commands = pytest --junitxml test-qiskit-{envname}.xml tests/unit/test_qiskit.py

0 commit comments

Comments
 (0)