summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorAnssi Kääriäinen <akaariai@gmail.com>2013-02-28 10:00:38 +0200
committerTim Graham <timograham@gmail.com>2013-07-24 07:33:03 -0400
commitb2314d9e1e08749f2c05151f9cd44520d2b3a03a (patch)
tree9bfba0bfa58ec1899befafed576e3c753f000914 /tests
parent372158a3cfedfc76d931f73cc3acf148babc4248 (diff)
Fixed #19941 -- Modified runtests.py to make running the tests easier.
1. Automatically use tests/../django as the Django version. 2. If settings aren't provided through --settings or DJANGO_SETTINGS_MODULE) then use test_sqlite.
Diffstat (limited to 'tests')
-rwxr-xr-xtests/runtests.py20
1 files changed, 16 insertions, 4 deletions
diff --git a/tests/runtests.py b/tests/runtests.py
index 8d5b375fb3..53318a7461 100755
--- a/tests/runtests.py
+++ b/tests/runtests.py
@@ -7,6 +7,20 @@ import sys
import tempfile
import warnings
+def upath(path):
+ """
+ Separate version of django.utils._os.upath. The django.utils version isn't
+ usable here, as upath is needed for RUNTESTS_DIR which is needed before
+ django can be imported.
+ """
+ if sys.version_info[0] != 3 and not isinstance(path, bytes):
+ fs_encoding = sys.getfilesystemencoding() or sys.getdefaultencoding()
+ return path.decode(fs_encoding)
+ return path
+
+RUNTESTS_DIR = os.path.abspath(os.path.dirname(upath(__file__)))
+sys.path.insert(0, os.path.dirname(RUNTESTS_DIR)) # 'tests/../'
+
from django import contrib
from django.utils._os import upath
from django.utils import six
@@ -15,7 +29,6 @@ CONTRIB_MODULE_PATH = 'django.contrib'
TEST_TEMPLATE_DIR = 'templates'
-RUNTESTS_DIR = os.path.abspath(os.path.dirname(upath(__file__)))
CONTRIB_DIR = os.path.dirname(upath(contrib.__file__))
TEMP_DIR = tempfile.mkdtemp(prefix='django_')
@@ -331,10 +344,9 @@ if __name__ == "__main__":
options, args = parser.parse_args()
if options.settings:
os.environ['DJANGO_SETTINGS_MODULE'] = options.settings
- elif "DJANGO_SETTINGS_MODULE" not in os.environ:
- parser.error("DJANGO_SETTINGS_MODULE is not set in the environment. "
- "Set it or use --settings.")
else:
+ if "DJANGO_SETTINGS_MODULE" not in os.environ:
+ os.environ['DJANGO_SETTINGS_MODULE'] = 'test_sqlite'
options.settings = os.environ['DJANGO_SETTINGS_MODULE']
if options.liveserver is not None: