|
@@ -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:
|