Add support for Projects in Testing by eleanorjboyd · Pull Request #25780 · microsoft/vscode-python

@eleanorjboyd

## Summary

This PR implements **project-based test discovery** for pytest, enabling
multi-project workspace support. When the Python Environments API is
available, the extension now discovers Python projects within workspaces
and creates separate test tree roots for each project with its own
Python environment.

## What's New

### Project-Based Testing Architecture
- **TestProjectRegistry**: Manages the lifecycle of Python test
projects, including:
  - Discovering projects via Python Environments API
  - Creating ProjectAdapter instances per workspace
  - Computing nested project relationships for ignore lists
  - Fallback to "legacy" single-adapter mode when API unavailable

- **ProjectAdapter**: Interface representing a single Python project
with test infrastructure:
  - Project identity (ID, name, URI)
  - Python environment from the environments API
  - Test framework adapters (discovery/execution)
  - Nested project ignore paths

### Key Features
- ✅ **Multi-project workspaces**: Each Python project gets its own test
tree root
- ✅ **Nested project handling**: Parent projects automatically ignore
nested child projects via `--ignore` flags
- ✅ **Graceful fallback**: Falls back to legacy single-adapter mode if
Python Environments API is unavailable
- ✅ **Project root path**: Python-side `get_test_root_path()` function
returns appropriate root for test tree

### Code Improvements
- Standardized logging prefixes to `[test-by-project]` across all files
- Centralized adapter creation via `createTestAdapters()` helper method
- Extracted reusable methods for discovery, execution, and file watching

## Scope & Limitations

> **⚠️ Important: unittest is NOT supported in this PR**
> 
> This PR focuses exclusively on **pytest**. unittest support for
project-based testing will be implemented in a future PR.

## Testing

- Added unit tests for `TestProjectRegistry` class
- Added unit tests for Python-side `get_test_root_path()` function
- Manual testing with multi-project workspaces

## Related Issues
first step in:
microsoft/vscode-python-environments#987

---------

Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com>