From 2e924ca787c706c03311931b64d8575af76b0c4f Mon Sep 17 00:00:00 2001 From: Shane Saravia Date: Thu, 9 Nov 2023 10:06:05 -0500 Subject: [PATCH 1/2] resolve import errors due to path ordering --- pythonFiles/unittestadapter/discovery.py | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/pythonFiles/unittestadapter/discovery.py b/pythonFiles/unittestadapter/discovery.py index 274fb5e5e663..8853189c4cc1 100644 --- a/pythonFiles/unittestadapter/discovery.py +++ b/pythonFiles/unittestadapter/discovery.py @@ -73,6 +73,11 @@ def discover_tests( } """ cwd = os.path.abspath(start_dir) + if '/' in start_dir: # is a subdir + parent_dir = os.path.dirname(start_dir) + sys.path.insert(0, parent_dir) + else: + sys.path.insert(0, cwd) payload: PayloadDict = {"cwd": cwd, "status": "success", "tests": None} tests = None error: List[str] = [] From 48a198fa12e33222f31dd7971b7ad69989d4f595 Mon Sep 17 00:00:00 2001 From: Shane Saravia Date: Tue, 14 Nov 2023 19:18:12 -0500 Subject: [PATCH 2/2] format using black --- pythonFiles/unittestadapter/discovery.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pythonFiles/unittestadapter/discovery.py b/pythonFiles/unittestadapter/discovery.py index 8853189c4cc1..e8f602a22fb3 100644 --- a/pythonFiles/unittestadapter/discovery.py +++ b/pythonFiles/unittestadapter/discovery.py @@ -73,7 +73,7 @@ def discover_tests( } """ cwd = os.path.abspath(start_dir) - if '/' in start_dir: # is a subdir + if "/" in start_dir: # is a subdir parent_dir = os.path.dirname(start_dir) sys.path.insert(0, parent_dir) else: