Unittest discovery using the new test adapter#18253
Merged
kimadeline merged 98 commits intomicrosoft:mainfrom Apr 13, 2022
Merged
Unittest discovery using the new test adapter#18253kimadeline merged 98 commits intomicrosoft:mainfrom
kimadeline merged 98 commits intomicrosoft:mainfrom
Conversation
added 21 commits
November 19, 2021 11:03
Co-authored-by: Brett Cannon <brett@python.org>
brettcannon
reviewed
Feb 2, 2022
Author
|
@karthiknadig @brettcannon I believe I addressed your comments, please come back for a third round of reviews 🥺 |
karthiknadig
reviewed
Feb 8, 2022
brettcannon
approved these changes
Feb 9, 2022
|
|
||
|
|
||
| class TestNode(TestData): | ||
| children: "List[TestNode | TestItem]" |
Member
There was a problem hiding this comment.
No need to make a change, but another way to deal with the forward references is to start the file with from __future__ import annotations, then you can ditch the quotes as Python will make all type annotations be strings.
Co-authored-by: Brett Cannon <brett@python.org>
karthiknadig
approved these changes
Apr 9, 2022
wesm
pushed a commit
to posit-dev/positron
that referenced
this pull request
Mar 28, 2024
…n#18253) * Basic test discovery (no server yet) * Clean up test discovery script * Add default test results array value (py side) * Add localization * Build tree on the Python side + move utils out * Basic test discovery * Add test tree update support * Multiroot workspace support * Make sure we don't shadow the "type" keyword * Move discovery in a function * Use pathlib everywhere * News entry * Add docstrings to utils tests + fix nested case * Rename utils tests data + delete unused files * Discovery tests * Update comments + requirements * Do not run test discovery for now * Re-generate requirements using python 3.7 * Sort Python imports on save * Get new server architecture up * Add comment for tornado * Apply Python suggestions from code review Co-authored-by: Brett Cannon <brett@python.org> * Pass test discovery adapter to workspace adapter * Wrap nodes under test provider * Let the OS pick a port * traceLog when response processing errors out Co-authored-by: Brett Cannon <brett@python.org>
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
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
For #17242
Known issues
Important TS classes and functions
The tl;dr of the architecture is:
Test UI↔️ PythonTestController (+ PythonTestServer) ↔️ WorkspaceTestAdapter ↔️ UnittestTestDiscoveryAdapter ↔️ Python side
And this PR introduces all the items in italics.
PythonTestServer(src/client/testing/testController/common/server.ts)Server for the client-server communication that implements the
ITestServerinterface. This server gets instantiated by thePythonTestControllerclass, and will stay alive for the duration of the session. It exposes asendCommandmethod that will send the test command, wait for a reply from the Python script, and emit an event with the response if the data comes from a trusted source (we use uuids for that). It is up to the event listeners to parse this data into a JSON object if the data cwd matches the workspace's uri.UnittestTestDiscoveryAdapter(src/client/testing/testController/unittest/testDiscoveryAdapter.ts)Wrapper class for unittest that implements the
ITestDiscoveryAdapterinterface. It only does one thing: unittest test discovery, and is the one that will callPythonTestServer.sendCommand.WorkspaceTestAdapter(src/client/testing/testController/workspaceTestAdapter.ts)The biggest chunk of logic in this PR.
This class exposes a test-provider-agnostic way of discovering tests. It gets instantiated by the
PythonTestControllerclass in charge of reflecting test data in the UI (one instance per workspace), and then instantiates aUnittestTestDiscoveryAdapterunder the hood depending on settings. Later on it will also support aPytestTestDiscoveryAdapter, and adapters for running and debugging tests.This class formats the JSON test data returned by the
UnittestTestDiscoveryAdapterinto test UI elements, and uses them to insert/update/remove items in theTestControllerinstance behind the testing UI whenever thePythonTestControllerrequests a refresh.