Skip to content

Commit 0e4181b

Browse files
authored
Handle pre-release pytest CI setup
1 parent 66ff9a4 commit 0e4181b

2 files changed

Lines changed: 21 additions & 9 deletions

File tree

.github/workflows/pr-check.yml

Lines changed: 13 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -172,6 +172,19 @@ jobs:
172172
with:
173173
python-version: ${{ matrix.python }}
174174

175+
- name: Install base Python requirements
176+
uses: brettcannon/pip-secure-install@92f400e3191171c1858cc0e0d9ac6320173fdb0c # v1.0.0
177+
with:
178+
requirements-file: '"${{ env.special-working-directory-relative }}/requirements.txt"'
179+
options: '-t "${{ env.special-working-directory-relative }}/python_files/lib/python" --no-cache-dir --implementation py'
180+
181+
- name: Install test requirements
182+
run: python -m pip install --upgrade -r build/test-requirements.txt
183+
184+
- name: Remove pytest-black for pre-release pytest
185+
if: matrix.pytest-version == 'pytest@pre-release'
186+
run: python -m pip uninstall -y pytest-black
187+
175188
- name: Install specific pytest version
176189
if: matrix.pytest-version == 'pytest@pre-release'
177190
run: |
@@ -184,14 +197,6 @@ jobs:
184197
185198
- name: Install specific pytest version
186199
run: python -m pytest --version
187-
- name: Install base Python requirements
188-
uses: brettcannon/pip-secure-install@92f400e3191171c1858cc0e0d9ac6320173fdb0c # v1.0.0
189-
with:
190-
requirements-file: '"${{ env.special-working-directory-relative }}/requirements.txt"'
191-
options: '-t "${{ env.special-working-directory-relative }}/python_files/lib/python" --no-cache-dir --implementation py'
192-
193-
- name: Install test requirements
194-
run: python -m pip install --upgrade -r build/test-requirements.txt
195200

196201
- name: Run Python unit tests
197202
run: python python_files/tests/run_all.py

python_files/tests/pytestadapter/test_discovery.py

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
# Copyright (c) Microsoft Corporation. All rights reserved.
22
# Licensed under the MIT License.
3+
import importlib.util
34
import json
45
import os
56
import pathlib
@@ -13,6 +14,8 @@
1314

1415
from . import expected_discovery_test_output, helpers
1516

17+
PYTEST_BLACK_AVAILABLE = importlib.util.find_spec("pytest_black") is not None
18+
1619

1720
def test_compact_discovery_payload_keeps_absolute_tree_until_return(tmp_path, monkeypatch):
1821
monkeypatch.setattr(vscode_pytest, "ERRORS", [])
@@ -476,10 +479,14 @@ def test_config_sub_folder():
476479
expected_discovery_test_output.ruff_test_expected_output,
477480
"--ruff",
478481
),
479-
(
482+
pytest.param(
480483
"2496-black-formatter",
481484
expected_discovery_test_output.black_formatter_expected_output,
482485
"--black",
486+
marks=pytest.mark.skipif(
487+
not PYTEST_BLACK_AVAILABLE,
488+
reason="pytest-black is not installed for this pytest environment",
489+
),
483490
),
484491
],
485492
)

0 commit comments

Comments
 (0)