You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: .github/instructions/testing_feature_area.instructions.md
+23-3Lines changed: 23 additions & 3 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -185,6 +185,22 @@ Project-based testing enables multi-project workspace support where each Python
185
185
- For unittest: `discovery.py` uses `PROJECT_ROOT_PATH` as `top_level_dir` and `cwd_override` to root the test tree at the project directory.
186
186
6.**Test tree**: Each project gets its own root node in the Test Explorer, with test IDs scoped by project ID using the `@@vsc@@` separator (defined in `projectUtils.ts`).
187
187
188
+
### Nested project handling: pytest vs unittest
189
+
190
+
**pytest** supports the `--ignore` flag to exclude paths during test collection. When nested projects are detected, parent projects automatically receive `--ignore` flags for child project paths. This ensures each test appears under exactly one project in the test tree.
191
+
192
+
**unittest** does not support path exclusion during `discover()`. Therefore, tests in nested project directories may appear under multiple project roots (both the parent and the child project). This is **expected behavior** for unittest:
193
+
194
+
- Each project discovers and displays all tests it finds within its directory structure
195
+
- There is no deduplication or collision detection
196
+
- Users may see the same test file under multiple project roots if their project structure has nesting
197
+
198
+
This approach was chosen because:
199
+
200
+
1. unittest's `TestLoader.discover()` has no built-in path exclusion mechanism
201
+
2. Implementing custom exclusion would add significant complexity with minimal benefit
202
+
3. The existing approach is transparent and predictable - each project shows what it finds
203
+
188
204
### Logging prefix
189
205
190
206
All project-based testing logs use the `[test-by-project]` prefix for easy filtering in the output channel.
@@ -193,15 +209,19 @@ All project-based testing logs use the `[test-by-project]` prefix for easy filte
193
209
194
210
- Python side:
195
211
-`python_files/vscode_pytest/__init__.py` — `get_test_root_path()` function and `PROJECT_ROOT_PATH` environment variable for pytest.
196
-
-`python_files/unittestadapter/discovery.py` — `discover_tests()` with `cwd_override` parameter and `PROJECT_ROOT_PATH` handling for unittest.
197
-
- TypeScript: `testProjectRegistry.ts`, `projectAdapter.ts`, `projectUtils.ts`, and the discovery adapters.
212
+
-`python_files/unittestadapter/discovery.py` — `discover_tests()` with `cwd_override` parameter and `PROJECT_ROOT_PATH` handling for unittest discovery.
213
+
-`python_files/unittestadapter/execution.py` — `run_tests()` with `cwd_override` parameter and `PROJECT_ROOT_PATH` handling for unittest execution.
214
+
- TypeScript: `testProjectRegistry.ts`, `projectAdapter.ts`, `projectUtils.ts`, and the discovery/execution adapters.
-`src/test/testing/testController/common/projectUtils.unit.test.ts` — Project utility function tests
203
220
-`python_files/tests/pytestadapter/test_discovery.py` — pytest PROJECT_ROOT_PATH tests (see `test_project_root_path_env_var()` and `test_symlink_with_project_root_path()`)
0 commit comments