Skip to content

testing: refine compact discovery payload review feedback#26000

Open
eleanorjboyd wants to merge 1 commit into
microsoft:mainfrom
eleanorjboyd:review-fixes-compact-payload
Open

testing: refine compact discovery payload review feedback#26000
eleanorjboyd wants to merge 1 commit into
microsoft:mainfrom
eleanorjboyd:review-fixes-compact-payload

Conversation

@eleanorjboyd

Copy link
Copy Markdown
Member

Follow-up to #25982 addressing review feedback.

What changed

  • Shared isAbsolutePath helper. Moved the cross-platform absolute-path check out of testDiscoveryHandler.ts and into src/client/common/platform/fs-paths.ts so it can be reused. The implementation now delegates to path.posix.isAbsolute || path.win32.isAbsolute instead of a hand-rolled regex. This is the right behavior here because the paths come from a Python subprocess and may be formatted for an OS different from the one currently running the extension.
  • Tightened create_class_node annotation. Replaced Any with pytest.Class | DescribeBlockType in python_files/vscode_pytest/__init__.py. DescribeBlockType is imported inside the existing if TYPE_CHECKING: block so it stays optional at runtime (matching the runtime DescribeBlock: Any = None fallback when pytest_describe is not installed).
  • Unit tests for isAbsolutePath. Added a 4-test suite in fs-paths.unit.test.ts covering POSIX absolute, Windows drive-letter, Windows UNC, and relative paths.

Verification

  • tsc --noEmit - cleanp .
  • eslint on touched cleanfiles
  • ruff check vscode_ cleanpytest/
  • pyright python_files/vscode_pytest/__init__. 0 errorspy
  • 4 new isAbsolutePath unit passtests
  • All 17 TestDiscoveryHandler unit still passtests
  • 3 compact_discovery_payload pytest passtests

Notes for reviewers

No behavior change is intended. The new isAbsolutePath is functionally equivalent to the regex it replaces (both recognize /foo, C:\foo, c:/foo, and \\server\share). The create_class_node signature change is purely a type-check improvement and has no runtime effect.

- Move isAbsolutePath helper to common/platform/fs-paths so it can be
  shared instead of duplicated inside testDiscoveryHandler. Uses
  path.posix.isAbsolute || path.win32.isAbsolute so paths produced on
  either OS (e.g. coming from a Python subprocess) are recognized.
- Tighten create_class_node annotation in vscode_pytest from Any to
  pytest.Class | DescribeBlockType. DescribeBlockType is imported under
  TYPE_CHECKING so it remains optional at runtime.
- Add unit tests for isAbsolutePath covering POSIX absolute,
  Windows drive-letter, UNC, and relative paths.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant