Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix django manage.py path validation #24019

Merged
merged 2 commits into from
Sep 3, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading