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

[PY-78960] Print import errors and exceptions when starting django_test_manage.py #2937

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
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
10 changes: 6 additions & 4 deletions python/helpers/pycharm/django_test_manage.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

import os
import sys
import traceback

from django.core.management import ManagementUtility

Expand All @@ -20,7 +21,8 @@
from django.conf import settings
apps = settings.INSTALLED_APPS
except:
pass
print("Exception while importing settings: {}".format(str(e)))
traceback.print_tb(e.__traceback__)

from django.core import management

Expand All @@ -30,9 +32,9 @@
sys.path.append(os.path.join(project_directory, os.pardir))
project_name = os.path.basename(os.path.normpath(project_directory))
__import__(project_name)
except ImportError:
# project has custom structure (project directory is not importable)
pass
except ImportError as e:
print("Exception while importing project directory {}: {}".format(project_directory, e))
traceback.print_tb(e.__traceback__)
finally:
sys.path.pop()

Expand Down