forked from DonJayamanne/pythonVSCode
-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
correct discovery on unittest skip at file level (#21665)
given a file called skip_test_file_node.py that has `raise SkipTest(".....")` this should appear in the sidebar with no children. The bug is that currently it shows a "unittest" node that gives "loader" and other incorrect nodes below it.
- Loading branch information
1 parent
be334bd
commit 713007f
Showing
5 changed files
with
124 additions
and
1 deletion.
There are no files selected for viewing
10 changes: 10 additions & 0 deletions
10
pythonFiles/tests/unittestadapter/.data/unittest_skip/unittest_skip_file.py
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
# Copyright (c) Microsoft Corporation. All rights reserved. | ||
# Licensed under the MIT License. | ||
|
||
from unittest import SkipTest | ||
|
||
raise SkipTest("This is unittest.SkipTest calling") | ||
|
||
|
||
def test_example(): | ||
assert 1 == 1 |
18 changes: 18 additions & 0 deletions
18
pythonFiles/tests/unittestadapter/.data/unittest_skip/unittest_skip_function.py
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
# Copyright (c) Microsoft Corporation. All rights reserved. | ||
# Licensed under the MIT License. | ||
|
||
import unittest | ||
|
||
|
||
def add(x, y): | ||
return x + y | ||
|
||
|
||
class SimpleTest(unittest.TestCase): | ||
@unittest.skip("demonstrating skipping") | ||
def testadd1(self): | ||
self.assertEquals(add(4, 5), 9) | ||
|
||
|
||
if __name__ == "__main__": | ||
unittest.main() |
68 changes: 68 additions & 0 deletions
68
pythonFiles/tests/unittestadapter/expected_discovery_test_output.py
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,68 @@ | ||
# Copyright (c) Microsoft Corporation. All rights reserved. | ||
# Licensed under the MIT License. | ||
|
||
import os | ||
from unittestadapter.utils import TestNodeTypeEnum | ||
from .helpers import TEST_DATA_PATH | ||
|
||
skip_unittest_folder_discovery_output = { | ||
"path": os.fspath(TEST_DATA_PATH / "unittest_skip"), | ||
"name": "unittest_skip", | ||
"type_": TestNodeTypeEnum.folder, | ||
"children": [ | ||
{ | ||
"path": os.fspath( | ||
TEST_DATA_PATH / "unittest_skip" / "unittest_skip_file.py" | ||
), | ||
"name": "unittest_skip_file.py", | ||
"type_": TestNodeTypeEnum.file, | ||
"children": [], | ||
"id_": os.fspath( | ||
TEST_DATA_PATH / "unittest_skip" / "unittest_skip_file.py" | ||
), | ||
}, | ||
{ | ||
"path": os.fspath( | ||
TEST_DATA_PATH / "unittest_skip" / "unittest_skip_function.py" | ||
), | ||
"name": "unittest_skip_function.py", | ||
"type_": TestNodeTypeEnum.file, | ||
"children": [ | ||
{ | ||
"path": os.fspath( | ||
TEST_DATA_PATH / "unittest_skip" / "unittest_skip_function.py" | ||
), | ||
"name": "SimpleTest", | ||
"type_": TestNodeTypeEnum.class_, | ||
"children": [ | ||
{ | ||
"name": "testadd1", | ||
"path": os.fspath( | ||
TEST_DATA_PATH | ||
/ "unittest_skip" | ||
/ "unittest_skip_function.py" | ||
), | ||
"lineno": "13", | ||
"type_": TestNodeTypeEnum.test, | ||
"id_": os.fspath( | ||
TEST_DATA_PATH | ||
/ "unittest_skip" | ||
/ "unittest_skip_function.py" | ||
) | ||
+ "\\SimpleTest\\testadd1", | ||
"runID": "unittest_skip_function.SimpleTest.testadd1", | ||
} | ||
], | ||
"id_": os.fspath( | ||
TEST_DATA_PATH / "unittest_skip" / "unittest_skip_function.py" | ||
) | ||
+ "\\SimpleTest", | ||
} | ||
], | ||
"id_": os.fspath( | ||
TEST_DATA_PATH / "unittest_skip" / "unittest_skip_function.py" | ||
), | ||
}, | ||
], | ||
"id_": os.fspath(TEST_DATA_PATH / "unittest_skip"), | ||
} |
This file contains 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
This file contains 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