From 44ecafbf64e7d3b840d6105333e8723abf070a70 Mon Sep 17 00:00:00 2001 From: eleanorjboyd <26030610+eleanorjboyd@users.noreply.github.com> Date: Wed, 13 Aug 2025 13:38:40 -0700 Subject: [PATCH 1/5] add msg for doctest support --- python_files/unittestadapter/pvsc_utils.py | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/python_files/unittestadapter/pvsc_utils.py b/python_files/unittestadapter/pvsc_utils.py index 017bad38966a..e77d15798b48 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 + ) + continue + print("post skip: test case", test_case) 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 From 87b1d59dde58acce1146026e75ecd1e130529348 Mon Sep 17 00:00:00 2001 From: eleanorjboyd <26030610+eleanorjboyd@users.noreply.github.com> Date: Wed, 13 Aug 2025 13:41:52 -0700 Subject: [PATCH 2/5] update test --- python_files/tests/unittestadapter/test_utils.py | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/python_files/tests/unittestadapter/test_utils.py b/python_files/tests/unittestadapter/test_utils.py index b0341ce37b63..2067bcf7baff 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.get("children") == [] + assert tests is not None assert not errors From f74e255deb6b59dba0af298aea8f32e14e5d4476 Mon Sep 17 00:00:00 2001 From: eleanorjboyd <26030610+eleanorjboyd@users.noreply.github.com> Date: Wed, 13 Aug 2025 13:43:06 -0700 Subject: [PATCH 3/5] add to error return --- python_files/unittestadapter/pvsc_utils.py | 1 + 1 file changed, 1 insertion(+) diff --git a/python_files/unittestadapter/pvsc_utils.py b/python_files/unittestadapter/pvsc_utils.py index e77d15798b48..e8aa7737b49b 100644 --- a/python_files/unittestadapter/pvsc_utils.py +++ b/python_files/unittestadapter/pvsc_utils.py @@ -207,6 +207,7 @@ def build_test_tree( 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 print("post skip: test case", test_case) test_id = test_case.id() From f403010328c700358bc021b809c51d21cd8c1c72 Mon Sep 17 00:00:00 2001 From: eleanorjboyd <26030610+eleanorjboyd@users.noreply.github.com> Date: Wed, 13 Aug 2025 13:43:49 -0700 Subject: [PATCH 4/5] remove left behind print --- python_files/unittestadapter/pvsc_utils.py | 1 - 1 file changed, 1 deletion(-) diff --git a/python_files/unittestadapter/pvsc_utils.py b/python_files/unittestadapter/pvsc_utils.py index e8aa7737b49b..09a5ec9f3be5 100644 --- a/python_files/unittestadapter/pvsc_utils.py +++ b/python_files/unittestadapter/pvsc_utils.py @@ -209,7 +209,6 @@ def build_test_tree( ) error = ["Skipping doctest as it is not supported for the extension."] continue - print("post skip: test case", test_case) test_id = test_case.id() if test_id.startswith("unittest.loader._FailedTest"): error.append(str(test_case._exception)) # type: ignore # noqa: SLF001 From d67c23446b629b23d6df6f8a00669e0ea3b6aa7c Mon Sep 17 00:00:00 2001 From: eleanorjboyd <26030610+eleanorjboyd@users.noreply.github.com> Date: Wed, 13 Aug 2025 13:51:25 -0700 Subject: [PATCH 5/5] fix pyright --- python_files/tests/unittestadapter/test_utils.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/python_files/tests/unittestadapter/test_utils.py b/python_files/tests/unittestadapter/test_utils.py index 2067bcf7baff..390b0779a44d 100644 --- a/python_files/tests/unittestadapter/test_utils.py +++ b/python_files/tests/unittestadapter/test_utils.py @@ -288,6 +288,6 @@ def test_build_empty_tree() -> None: suite = loader.discover(start_dir, pattern) tests, errors = build_test_tree(suite, start_dir) - assert tests.get("children") == [] assert tests is not None + assert tests.get("children") == [] assert not errors