forked from DonJayamanne/pythonVSCode
-
Notifications
You must be signed in to change notification settings - Fork 1.3k
Fix pytest CI matrix compatibility and prevent hangs #26027
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
12 commits
Select commit
Hold shift + click to select a range
e414347
Initial plan
Copilot c44d10b
Reorder pr-check.yml so specific pytest version installs after test-r…
Copilot a903338
Fix failing Python Tests CI job by preserving pytest<8.1 pin for pyte…
Copilot cdb5ddf
Replace pytest-black with local conftest; remove pytest<8.1 pin
Copilot 43a5c24
Use text=True in subprocess.run; document why path param must match h…
Copilot 12f4145
Fix pytest 6.2 CI lane plugin compatibility installs
Copilot 50a2522
Fix pytest CI matrix and prevent pipe hangs
eleanorjboyd b9fe1a4
Test supported Python versions against recent pytest
eleanorjboyd c15488a
Fix pytest test harness type errors
eleanorjboyd 367dd0e
Skip obsolete pytest-black discovery case
eleanorjboyd c458145
Format pytest discovery test
eleanorjboyd 18922ea
Restore pytest plugin autoload CLI option
eleanorjboyd File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,54 @@ | ||
| # Copyright (c) Microsoft Corporation. All rights reserved. | ||
| # Licensed under the MIT License. | ||
|
|
||
| import os | ||
| import subprocess | ||
| import sys | ||
| import threading | ||
|
|
||
| import pytest | ||
|
|
||
| from . import helpers | ||
|
|
||
|
|
||
| def test_run_test_code_times_out(tmp_path, monkeypatch): | ||
| monkeypatch.setattr(helpers, "TEST_SUBPROCESS_TIMEOUT_SECONDS", 0.01) | ||
| completed = threading.Event() | ||
|
|
||
| with pytest.raises(subprocess.TimeoutExpired): | ||
| helpers._run_test_code( # noqa: SLF001 | ||
| [sys.executable, "-c", "import time; time.sleep(1)"], | ||
| os.environ.copy(), | ||
| str(tmp_path), | ||
| completed, | ||
| ) | ||
|
|
||
| assert completed.is_set() | ||
|
|
||
|
|
||
| def test_wait_for_pipe_result_surfaces_subprocess_failure(): | ||
| listener_thread = threading.Thread(target=lambda: None) | ||
| listener_thread.start() | ||
| process_result = subprocess.CompletedProcess(["pytest"], returncode=2) | ||
|
|
||
| with pytest.raises(subprocess.CalledProcessError): | ||
| helpers._wait_for_pipe_result( # noqa: SLF001 | ||
| listener_thread, process_result, [] | ||
| ) | ||
|
|
||
|
|
||
| def test_wait_for_pipe_result_times_out(monkeypatch): | ||
| monkeypatch.setattr(helpers, "PIPE_RESULT_TIMEOUT_SECONDS", 0.01) | ||
| release_listener = threading.Event() | ||
| listener_thread = threading.Thread(target=release_listener.wait, daemon=True) | ||
| listener_thread.start() | ||
| process_result = subprocess.CompletedProcess(["pytest"], returncode=0) | ||
|
|
||
| try: | ||
| with pytest.raises(TimeoutError, match="Timed out waiting"): | ||
| helpers._wait_for_pipe_result( # noqa: SLF001 | ||
| listener_thread, process_result, [] | ||
| ) | ||
| finally: | ||
| release_listener.set() | ||
| listener_thread.join() |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.