Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit ede5b3d

Browse filesBrowse files
authored
Add commands to run, debug and open tests (#4332)
For #4277
1 parent e8aa187 commit ede5b3d
Copy full SHA for ede5b3d

19 files changed

+409-46Lines changed: 409 additions & 46 deletions

File tree

Expand file treeCollapse file tree
Open diff view settings
Filter options
Expand file treeCollapse file tree
Open diff view settings
Collapse file

‎package.json‎

Copy file name to clipboardExpand all lines: package.json
+89Lines changed: 89 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -143,6 +143,30 @@
143143
"title": "%python.command.python.buildWorkspaceSymbols.title%",
144144
"category": "Python"
145145
},
146+
{
147+
"command": "python.openTestNodeInEditor",
148+
"title": "Open",
149+
"icon": {
150+
"light": "resources/light/open-file.svg",
151+
"dark": "resources/dark/open-file.svg"
152+
}
153+
},
154+
{
155+
"command": "python.runTestNode",
156+
"title": "Run",
157+
"icon": {
158+
"light": "resources/light/start.svg",
159+
"dark": "resources/dark/start.svg"
160+
}
161+
},
162+
{
163+
"command": "python.debugTestNode",
164+
"title": "Debug",
165+
"icon": {
166+
"light": "resources/light/debug.svg",
167+
"dark": "resources/dark/debug.svg"
168+
}
169+
},
146170
{
147171
"command": "python.runtests",
148172
"title": "%python.command.python.runtests.title%",
@@ -439,6 +463,24 @@
439463
}
440464
],
441465
"commandPalette": [
466+
{
467+
"command": "python.runTestNode",
468+
"title": "Run",
469+
"category": "Python",
470+
"when": "config.noExists"
471+
},
472+
{
473+
"command": "python.debugTestNode",
474+
"title": "Debug",
475+
"category": "Python",
476+
"when": "config.noExists"
477+
},
478+
{
479+
"command": "python.openTestNodeInEditor",
480+
"title": "Open",
481+
"category": "Python",
482+
"when": "config.noExists"
483+
},
442484
{
443485
"command": "python.datascience.runcurrentcell",
444486
"title": "%python.command.python.datascience.runcurrentcell.title%",
@@ -540,6 +582,53 @@
540582
"command": "python.runtests",
541583
"group": "navigation"
542584
}
585+
],
586+
"view/item/context": [
587+
{
588+
"command": "python.openTestNodeInEditor",
589+
"when": "view == python_tests && viewItem == testFunction",
590+
"group": "inline"
591+
},
592+
{
593+
"command": "python.debugTestNode",
594+
"when": "view == python_tests && viewItem == testFunction",
595+
"group": "inline"
596+
},
597+
{
598+
"command": "python.runTestNode",
599+
"when": "view == python_tests && viewItem == testFunction",
600+
"group": "inline"
601+
},
602+
{
603+
"command": "python.openTestNodeInEditor",
604+
"when": "view == python_tests && viewItem == testFile",
605+
"group": "inline"
606+
},
607+
{
608+
"command": "python.debugTestNode",
609+
"when": "view == python_tests && viewItem == testFile",
610+
"group": "inline"
611+
},
612+
{
613+
"command": "python.runTestNode",
614+
"when": "view == python_tests && viewItem == testFile",
615+
"group": "inline"
616+
},
617+
{
618+
"command": "python.openTestNodeInEditor",
619+
"when": "view == python_tests && viewItem == testSuite",
620+
"group": "inline"
621+
},
622+
{
623+
"command": "python.debugTestNode",
624+
"when": "view == python_tests && viewItem == testSuite",
625+
"group": "inline"
626+
},
627+
{
628+
"command": "python.runTestNode",
629+
"when": "view == python_tests && viewItem == testSuite",
630+
"group": "inline"
631+
}
543632
]
544633
},
545634
"debuggers": [
Collapse file

‎pythonFiles/symbolProvider.py‎

Copy file name to clipboardExpand all lines: pythonFiles/symbolProvider.py
+2-2Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ def getDataObject(self, node, namespace=""):
4747
"name": node.name,
4848
"range": {
4949
"start": {
50-
"line": node.lineno,
50+
"line": node.lineno - 1,
5151
"character": node.col_offset
5252
},
5353
"end": {
@@ -59,7 +59,7 @@ def getDataObject(self, node, namespace=""):
5959

6060
def getEndPosition(self, node):
6161
if not hasattr(node, 'body') or len(node.body) == 0:
62-
return (node.lineno, node.col_offset)
62+
return (node.lineno - 1, node.col_offset)
6363
return self.getEndPosition(node.body[-1])
6464

6565

Collapse file

‎resources/dark/debug.svg‎

Copy file name to clipboard
+7Lines changed: 7 additions & 0 deletions
  • Display the source diff
  • Display the rich diff
Loading
Collapse file

‎resources/dark/open-file.svg‎

Copy file name to clipboard
+1Lines changed: 1 addition & 0 deletions
  • Display the source diff
  • Display the rich diff
Loading
Collapse file

‎resources/dark/start.svg‎

Copy file name to clipboard
+1Lines changed: 1 addition & 0 deletions
  • Display the source diff
  • Display the rich diff
Loading
Collapse file

‎resources/light/debug.svg‎

Copy file name to clipboard
+7Lines changed: 7 additions & 0 deletions
  • Display the source diff
  • Display the rich diff
Loading
Collapse file

‎resources/light/open-file.svg‎

Copy file name to clipboard
+1Lines changed: 1 addition & 0 deletions
  • Display the source diff
  • Display the rich diff
Loading
Collapse file

‎resources/light/start.svg‎

Copy file name to clipboard
+1Lines changed: 1 addition & 0 deletions
  • Display the source diff
  • Display the rich diff
Loading
Collapse file

‎src/client/common/constants.ts‎

Copy file name to clipboardExpand all lines: src/client/common/constants.ts
+3Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,9 @@ export namespace Commands {
4545
export const navigateToTestFunction = 'navigateToTestFunction';
4646
export const navigateToTestSuite = 'navigateToTestSuite';
4747
export const navigateToTestFile = 'navigateToTestFile';
48+
export const openTestNodeInEditor = 'python.openTestNodeInEditor';
49+
export const runTestNode = 'python.runTestNode';
50+
export const debugTestNode = 'python.debugTestNode';
4851
}
4952
export namespace Octicons {
5053
export const Test_Pass = '$(check)';
Collapse file

‎src/client/extension.ts‎

Copy file name to clipboardExpand all lines: src/client/extension.ts
+2-1Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,7 @@ import { EditorLoadTelemetry } from './telemetry/types';
101101
import { registerTypes as commonRegisterTerminalTypes } from './terminals/serviceRegistry';
102102
import { ICodeExecutionManager, ITerminalAutoActivation } from './terminals/types';
103103
import { TEST_OUTPUT_CHANNEL } from './unittests/common/constants';
104-
import { ITestCodeNavigatorCommandHandler } from './unittests/navigation/types';
104+
import { ITestCodeNavigatorCommandHandler, ITestExplorerCommandHandler } from './unittests/navigation/types';
105105
import { registerTypes as unitTestsRegisterTypes } from './unittests/serviceRegistry';
106106

107107
durations.codeLoadingTime = stopWatch.elapsedTime;
@@ -293,6 +293,7 @@ function initializeServices(context: ExtensionContext, serviceManager: ServiceMa
293293
serviceContainer.get<IInterpreterLocatorProgressService>(IInterpreterLocatorProgressService).register();
294294
serviceContainer.get<IApplicationDiagnostics>(IApplicationDiagnostics).register();
295295
serviceContainer.get<ITestCodeNavigatorCommandHandler>(ITestCodeNavigatorCommandHandler).register();
296+
serviceContainer.get<ITestExplorerCommandHandler>(ITestExplorerCommandHandler).register();
296297
}
297298

298299
// tslint:disable-next-line:no-any

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.