Skip to content

Commit

Permalink
fix django manage.py path validation (#24019) (#24045)
Browse files Browse the repository at this point in the history
fixes #24001, cherry
pick into release
  • Loading branch information
eleanorjboyd committed Sep 4, 2024
1 parent eb0ed8e commit 873c398
Showing 1 changed file with 4 additions and 8 deletions.
12 changes: 4 additions & 8 deletions python_files/unittestadapter/django_handler.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,8 @@

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

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

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

try:
# Get path to the custom_test_runner.py parent folder, add to sys.path.
Expand Down

0 comments on commit 873c398

Please sign in to comment.