diff --git a/python_files/tests/unittestadapter/test_utils.py b/python_files/tests/unittestadapter/test_utils.py index b0341ce37b63..390b0779a44d 100644 --- a/python_files/tests/unittestadapter/test_utils.py +++ b/python_files/tests/unittestadapter/test_utils.py @@ -284,11 +284,10 @@ def test_build_empty_tree() -> None: start_dir = os.fsdecode(TEST_DATA_PATH) pattern = "does_not_exist*" - expected = None - loader = unittest.TestLoader() suite = loader.discover(start_dir, pattern) tests, errors = build_test_tree(suite, start_dir) - assert expected == tests + assert tests is not None + assert tests.get("children") == [] assert not errors diff --git a/python_files/unittestadapter/pvsc_utils.py b/python_files/unittestadapter/pvsc_utils.py index 017bad38966a..09a5ec9f3be5 100644 --- a/python_files/unittestadapter/pvsc_utils.py +++ b/python_files/unittestadapter/pvsc_utils.py @@ -3,6 +3,7 @@ import argparse import atexit +import doctest import enum import inspect import json @@ -202,6 +203,12 @@ def build_test_tree( root = build_test_node(top_level_directory, directory_path.name, TestNodeTypeEnum.folder) for test_case in get_test_case(suite): + if isinstance(test_case, doctest.DocTestCase): + print( + "Skipping doctest as it is not supported for the extension. Test case: ", test_case + ) + error = ["Skipping doctest as it is not supported for the extension."] + continue test_id = test_case.id() if test_id.startswith("unittest.loader._FailedTest"): error.append(str(test_case._exception)) # type: ignore # noqa: SLF001 @@ -255,9 +262,6 @@ def build_test_tree( } # concatenate class name and function test name current_node["children"].append(test_node) - if not root["children"]: - root = None - return root, error