Skip to content

Commit cc8b3de

Browse files
authored
msg for doctest unsupported (#25387)
fixes #25380
1 parent 5b59591 commit cc8b3de

File tree

2 files changed

+9
-6
lines changed

2 files changed

+9
-6
lines changed

python_files/tests/unittestadapter/test_utils.py

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -284,11 +284,10 @@ def test_build_empty_tree() -> None:
284284
start_dir = os.fsdecode(TEST_DATA_PATH)
285285
pattern = "does_not_exist*"
286286

287-
expected = None
288-
289287
loader = unittest.TestLoader()
290288
suite = loader.discover(start_dir, pattern)
291289
tests, errors = build_test_tree(suite, start_dir)
292290

293-
assert expected == tests
291+
assert tests is not None
292+
assert tests.get("children") == []
294293
assert not errors

python_files/unittestadapter/pvsc_utils.py

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33

44
import argparse
55
import atexit
6+
import doctest
67
import enum
78
import inspect
89
import json
@@ -202,6 +203,12 @@ def build_test_tree(
202203
root = build_test_node(top_level_directory, directory_path.name, TestNodeTypeEnum.folder)
203204

204205
for test_case in get_test_case(suite):
206+
if isinstance(test_case, doctest.DocTestCase):
207+
print(
208+
"Skipping doctest as it is not supported for the extension. Test case: ", test_case
209+
)
210+
error = ["Skipping doctest as it is not supported for the extension."]
211+
continue
205212
test_id = test_case.id()
206213
if test_id.startswith("unittest.loader._FailedTest"):
207214
error.append(str(test_case._exception)) # type: ignore # noqa: SLF001
@@ -255,9 +262,6 @@ def build_test_tree(
255262
} # concatenate class name and function test name
256263
current_node["children"].append(test_node)
257264

258-
if not root["children"]:
259-
root = None
260-
261265
return root, error
262266

263267

0 commit comments

Comments
 (0)