Add line number support for class nodes in pytest and unittest by eleanorjboyd · Pull Request #25593 · microsoft/vscode-python
AI and others added 7 commits
November 14, 2025 15:53- Modified create_class_node() to extract and include line number using inspect.getsourcelines() - Updated TypeScript types to allow optional lineno on DiscoveredTestNode - Modified populateTestTree() to handle lineno for class nodes (not just test items) - Added find_class_line_number() helper function for test expectations - Updated all test expectations to include lineno for class nodes - Added 'function' to DiscoveredTestType enum This enables TestClass items to show the green arrow and be runnable in VS Code's Test Explorer. Co-authored-by: eleanorjboyd <26030610+eleanorjboyd@users.noreply.github.com>
- Added NotRequired to imports for optional TypedDict fields - Made lineno an optional field in TestNode TypedDict - Formatted Python files with ruff Co-authored-by: eleanorjboyd <26030610+eleanorjboyd@users.noreply.github.com>
- Modified build_test_tree() in pvsc_utils.py to add line numbers to class nodes - Added get_class_line() function to extract class line numbers using inspect - Made lineno an optional field in TestNode TypedDict - Added find_class_line_number() helper for test expectations - Updated expected test outputs to include lineno for class nodes This implements the same functionality for unittest as was done for pytest, enabling TestClass items to show the green arrow and be runnable in VS Code's Test Explorer. Co-authored-by: eleanorjboyd <26030610+eleanorjboyd@users.noreply.github.com>
…ermined Changed get_class_line() to return "" instead of "*" when inspect.getsourcelines() fails, making it consistent with the pytest implementation and leaving the field blank when the line number cannot be determined. Co-authored-by: eleanorjboyd <26030610+eleanorjboyd@users.noreply.github.com>
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