FazBrowse GitHub Viewer | Trending |
URL:
| Home
Tools: [Download Repo ZIP]   [Original HTTPS Page]

Enhance pytest installation flow and error handling with Environment Extension integration by Copilot · Pull Request #25252 · microsoft/vscode-python · GitHub

Enhance pytest installation flow and error handling with Environment Extension integration - #25252

Merged
Eleanor Boyd (eleanorjboyd) merged 9 commits into
mainfrom
copilot/fix-25251
Jul 10, 2025
Merged

Enhance pytest installation flow and error handling with Environment Extension integration#25252
Eleanor Boyd (eleanorjboyd) merged 9 commits into
mainfrom
copilot/fix-25251

Conversation

Copilot AI commented Jul 8, 2025
edited by eleanorjboyd
Loading

Copy link
Copy Markdown

Overview

This PR addresses the issue where pytest configuration attempts would proceed without user confirmation when pytest is not installed, and provides better error messages when pytest installation issues occur.

Changes Made

1. Enhanced User Prompt for pytest Installation

Before: Extension would silently attempt to install pytest without user input.

After: Shows a user-friendly prompt when pytest is selected but not installed:

pytest selected but not installed. Would you like to install pytest?
[Install pytest] [Ignore]

2. Python Environments Extension Integration

When the Python Environments extension is available:

  • Uses the managePackages API for proper environment-targeted installation
  • Ensures pytest is installed in the correct Python environment
  • Provides better integration with the extension ecosystem

New Class: PytestInstallationHelper handles the enhanced installation flow with fallback to traditional installer when the environment extension is not available.

Technical Implementation

  • New: src/client/testing/configuration/pytestInstallationHelper.ts - Handles enhanced installation flow
  • Enhanced: src/client/testing/configuration/pytest/testConfigurationManager.ts - Integrates new installation helper
  • Enhanced: src/client/testing/testController/common/utils.ts - Improved error message detection
  • Comprehensive test coverage with unit tests for all scenarios

Fixes #25251.
also fixes #17772

Co-authored-by: eleanorjboyd <26030610+eleanorjboyd@users.noreply.github.com>
Copilot AI changed the title [WIP] pytest not installed but selected for configuration updates Enhance pytest installation flow and error handling with Environment Extension integration Jul 8, 2025
Eleanor Boyd (eleanorjboyd) added the debt Code quality issues label Jul 8, 2025
Eleanor Boyd (eleanorjboyd) marked this pull request as ready for review July 8, 2025 20:10
Eleanor Boyd (eleanorjboyd) added skip tests Updates to tests unnecessary skip package*.json package.json and package-lock.json don't both need updating and removed skip tests Updates to tests unnecessary labels Jul 8, 2025
vs-code-engineering Bot added this to the July 2025 milestone Jul 8, 2025

Copy link
Copy Markdown

I see that we show the notification pop-up suggesting Pytest when configuring test for new repo.
Did we also wanted to edit what shows up in pytest Discvoery Error?

Copilot AI commented Jul 9, 2025

Copy link
Copy Markdown
Author

I see that we show the notification pop-up suggesting Pytest when configuring test for new repo.
Did we also wanted to edit what shows up in pytest Discvoery Error?
<img width="1722" alt="Screens...

Yes, I've enhanced the "pytest Discovery Error" message to be more user-friendly and actionable!

The discovery error now shows:

  • Before: "pytest Discovery Error" with only "Show output" link
  • After: "pytest Not Installed" with "Install pytest | Show output" when pytest is not installed

This provides the same user-friendly experience as the configuration flow, allowing users to install pytest directly from the discovery error message. The implementation includes:

  1. Added python.installPytest command that uses the existing PytestInstallationHelper
  2. Enhanced error messages to include installation link when pytest is not installed
  3. Automatically refreshes test data after successful installation

Commit: 3d371b1

Copy link
Copy Markdown
Member

I don't think so- the error message is still relevant and has a different lifetime so I think its good as is

Copy link
Copy Markdown
Member

Copilot can you switch the popup that asks the user if they want to install pytest (if they have the environments extension) to a modal so it takes up the whole screen and is more "in your face" to the user.

Co-authored-by: eleanorjboyd <26030610+eleanorjboyd@users.noreply.github.com>

Copilot AI commented Jul 9, 2025

Copy link
Copy Markdown
Author

Copilot can you switch the popup that asks the user if they want to install pytest (if they have the environments extension) to a modal so it takes up the whole screen and is more "in your face" to t...

Done! The pytest installation prompt now shows as a modal dialog instead of a popup notification. This makes it more prominent and requires explicit user action before they can continue. Commit: 272c601

Copy link
Copy Markdown


Looks fine other than lint fails

Co-authored-by: anthonykim1 <62267334+anthonykim1@users.noreply.github.com>

Copilot AI commented Jul 9, 2025

Copy link
Copy Markdown
Author


Looks fine other than lint fails

Fixed the formatting issues in the test files. The lint failure was due to prettier formatting requirements for long method calls. Commit: f752cb1

Eleanor Boyd (eleanorjboyd) enabled auto-merge (squash) July 10, 2025 22:10
Eleanor Boyd (eleanorjboyd) merged commit 81f3397 into main Jul 10, 2025
85 checks passed
Eleanor Boyd (eleanorjboyd) deleted the copilot/fix-25251 branch July 10, 2025 22:18
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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

debt Code quality issues skip package*.json package.json and package-lock.json don't both need updating skip-issue-check

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Improve feedback when user tries a pytest test when pytest is not installed, but is selected as the testing library

4 participants


Back | FazBrowse Home | New Git URL