Skip to content

Commit 0c46b63

Browse files
committed
fix django manage.py path validation (microsoft#24019)
fixes microsoft#24001
1 parent eb0ed8e commit 0c46b63

File tree

1 file changed

+4
-8
lines changed

1 file changed

+4
-8
lines changed

python_files/unittestadapter/django_handler.py

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -18,10 +18,8 @@
1818

1919
def django_discovery_runner(manage_py_path: str, args: List[str]) -> None:
2020
# Attempt a small amount of validation on the manage.py path.
21-
try:
22-
pathlib.Path(manage_py_path)
23-
except Exception as e:
24-
raise VSCodeUnittestError(f"Error running Django, manage.py path is not a valid path: {e}") # noqa: B904
21+
if not pathlib.Path(manage_py_path).exists():
22+
raise VSCodeUnittestError("Error running Django, manage.py path does not exist.")
2523

2624
try:
2725
# Get path to the custom_test_runner.py parent folder, add to sys.path and new environment used for subprocess.
@@ -61,10 +59,8 @@ def django_discovery_runner(manage_py_path: str, args: List[str]) -> None:
6159

6260
def django_execution_runner(manage_py_path: str, test_ids: List[str], args: List[str]) -> None:
6361
# Attempt a small amount of validation on the manage.py path.
64-
try:
65-
pathlib.Path(manage_py_path)
66-
except Exception as e:
67-
raise VSCodeUnittestError(f"Error running Django, manage.py path is not a valid path: {e}") # noqa: B904
62+
if not pathlib.Path(manage_py_path).exists():
63+
raise VSCodeUnittestError("Error running Django, manage.py path does not exist.")
6864

6965
try:
7066
# Get path to the custom_test_runner.py parent folder, add to sys.path.

0 commit comments

Comments
 (0)