-
Notifications
You must be signed in to change notification settings - Fork 1.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Unittest discovery using the new test adapter #18253
Unittest discovery using the new test adapter #18253
Conversation
Co-authored-by: Brett Cannon <brett@python.org>
@karthiknadig @brettcannon I believe I addressed your comments, please come back for a third round of reviews 🥺 |
|
||
|
||
class TestNode(TestData): | ||
children: "List[TestNode | TestItem]" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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>
…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>
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
ITestServer
interface. This server gets instantiated by thePythonTestController
class, and will stay alive for the duration of the session. It exposes asendCommand
method 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
ITestDiscoveryAdapter
interface. 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
PythonTestController
class in charge of reflecting test data in the UI (one instance per workspace), and then instantiates aUnittestTestDiscoveryAdapter
under 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
UnittestTestDiscoveryAdapter
into test UI elements, and uses them to insert/update/remove items in theTestController
instance behind the testing UI whenever thePythonTestController
requests a refresh.