diff options
| author | Thomas Allison <thomas.allison@byte.nl> | 2019-04-13 12:54:03 +0200 |
|---|---|---|
| committer | Mariusz Felisiak <felisiak.mariusz@gmail.com> | 2019-04-13 16:06:27 +0200 |
| commit | 3e8b7333904f1ab6aa18eeb508659256f3644816 (patch) | |
| tree | 0ebcb560213ea53b9eb297bc9d865e28fec99974 | |
| parent | e6d57c4d652f16ac8f8d4600c0b7c30fcfcde6c2 (diff) | |
Fixed #25941 -- Improved error message for runtests.py when django is not on path.
| -rwxr-xr-x | tests/runtests.py | 30 |
1 files changed, 18 insertions, 12 deletions
diff --git a/tests/runtests.py b/tests/runtests.py index 0861ec8798..a0b429b6df 100755 --- a/tests/runtests.py +++ b/tests/runtests.py @@ -10,18 +10,24 @@ import sys import tempfile import warnings -import django -from django.apps import apps -from django.conf import settings -from django.db import connection, connections -from django.test import TestCase, TransactionTestCase -from django.test.runner import default_test_processes -from django.test.selenium import SeleniumTestCaseBase -from django.test.utils import get_runner -from django.utils.deprecation import ( - RemovedInDjango31Warning, RemovedInDjango40Warning, -) -from django.utils.log import DEFAULT_LOGGING +try: + import django +except ImportError as e: + raise RuntimeError( + 'Django module not found, reference tests/README.rst for instructions.' + ) from e +else: + from django.apps import apps + from django.conf import settings + from django.db import connection, connections + from django.test import TestCase, TransactionTestCase + from django.test.runner import default_test_processes + from django.test.selenium import SeleniumTestCaseBase + from django.test.utils import get_runner + from django.utils.deprecation import ( + RemovedInDjango31Warning, RemovedInDjango40Warning, + ) + from django.utils.log import DEFAULT_LOGGING try: import MySQLdb |
