mirror of https://github.com/django/django.git
Modified the django system test script to search for tests in the contrib apps.
git-svn-id: http://code.djangoproject.com/svn/django/trunk@5296 bcc190cf-cafb-0310-a4f2-bffc1f526a37
This commit is contained in:
parent
d43522b077
commit
c9aa4c71ac
|
@ -0,0 +1,17 @@
|
||||||
|
# -*- coding: utf-8 -*-
|
||||||
|
|
||||||
|
r"""
|
||||||
|
>>> words(7)
|
||||||
|
'lorem ipsum dolor sit amet consectetur adipisicing'
|
||||||
|
|
||||||
|
>>> paragraphs(1)
|
||||||
|
['Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.']
|
||||||
|
|
||||||
|
"""
|
||||||
|
|
||||||
|
from django.contrib.webdesign.lorem_ipsum import *
|
||||||
|
import datetime
|
||||||
|
|
||||||
|
if __name__ == '__main__':
|
||||||
|
import doctest
|
||||||
|
doctest.testmod()
|
|
@ -3,11 +3,15 @@
|
||||||
import os, sys, traceback
|
import os, sys, traceback
|
||||||
import unittest
|
import unittest
|
||||||
|
|
||||||
|
import django.contrib as contrib
|
||||||
|
CONTRIB_DIR_NAME = 'django.contrib'
|
||||||
MODEL_TESTS_DIR_NAME = 'modeltests'
|
MODEL_TESTS_DIR_NAME = 'modeltests'
|
||||||
REGRESSION_TESTS_DIR_NAME = 'regressiontests'
|
REGRESSION_TESTS_DIR_NAME = 'regressiontests'
|
||||||
|
|
||||||
TEST_DATABASE_NAME = 'django_test_db'
|
TEST_DATABASE_NAME = 'django_test_db'
|
||||||
TEST_TEMPLATE_DIR = 'templates'
|
TEST_TEMPLATE_DIR = 'templates'
|
||||||
|
|
||||||
|
CONTRIB_DIR = os.path.dirname(contrib.__file__)
|
||||||
MODEL_TEST_DIR = os.path.join(os.path.dirname(__file__), MODEL_TESTS_DIR_NAME)
|
MODEL_TEST_DIR = os.path.join(os.path.dirname(__file__), MODEL_TESTS_DIR_NAME)
|
||||||
REGRESSION_TEST_DIR = os.path.join(os.path.dirname(__file__), REGRESSION_TESTS_DIR_NAME)
|
REGRESSION_TEST_DIR = os.path.join(os.path.dirname(__file__), REGRESSION_TESTS_DIR_NAME)
|
||||||
|
|
||||||
|
@ -24,7 +28,7 @@ ALWAYS_INSTALLED_APPS = [
|
||||||
|
|
||||||
def get_test_models():
|
def get_test_models():
|
||||||
models = []
|
models = []
|
||||||
for loc, dirpath in (MODEL_TESTS_DIR_NAME, MODEL_TEST_DIR), (REGRESSION_TESTS_DIR_NAME, REGRESSION_TEST_DIR):
|
for loc, dirpath in (MODEL_TESTS_DIR_NAME, MODEL_TEST_DIR), (REGRESSION_TESTS_DIR_NAME, REGRESSION_TEST_DIR), (CONTRIB_DIR_NAME, CONTRIB_DIR):
|
||||||
for f in os.listdir(dirpath):
|
for f in os.listdir(dirpath):
|
||||||
if f.startswith('__init__') or f.startswith('.') or f.startswith('sql') or f.startswith('invalid'):
|
if f.startswith('__init__') or f.startswith('.') or f.startswith('sql') or f.startswith('invalid'):
|
||||||
continue
|
continue
|
||||||
|
@ -33,7 +37,7 @@ def get_test_models():
|
||||||
|
|
||||||
def get_invalid_models():
|
def get_invalid_models():
|
||||||
models = []
|
models = []
|
||||||
for loc, dirpath in (MODEL_TESTS_DIR_NAME, MODEL_TEST_DIR), (REGRESSION_TESTS_DIR_NAME, REGRESSION_TEST_DIR):
|
for loc, dirpath in (MODEL_TESTS_DIR_NAME, MODEL_TEST_DIR), (REGRESSION_TESTS_DIR_NAME, REGRESSION_TEST_DIR), (CONTRIB_DIR_NAME, CONTRIB_DIR):
|
||||||
for f in os.listdir(dirpath):
|
for f in os.listdir(dirpath):
|
||||||
if f.startswith('__init__') or f.startswith('.') or f.startswith('sql'):
|
if f.startswith('__init__') or f.startswith('.') or f.startswith('sql'):
|
||||||
continue
|
continue
|
||||||
|
@ -109,8 +113,10 @@ def django_tests(verbosity, tests_to_run):
|
||||||
if verbosity >= 1:
|
if verbosity >= 1:
|
||||||
print "Importing model %s" % model_name
|
print "Importing model %s" % model_name
|
||||||
mod = load_app(model_label)
|
mod = load_app(model_label)
|
||||||
settings.INSTALLED_APPS.append(model_label)
|
if mod:
|
||||||
test_models.append(mod)
|
if model_label not in settings.INSTALLED_APPS:
|
||||||
|
settings.INSTALLED_APPS.append(model_label)
|
||||||
|
test_models.append(mod)
|
||||||
except Exception, e:
|
except Exception, e:
|
||||||
sys.stderr.write("Error while importing %s:" % model_name + ''.join(traceback.format_exception(*sys.exc_info())[1:]))
|
sys.stderr.write("Error while importing %s:" % model_name + ''.join(traceback.format_exception(*sys.exc_info())[1:]))
|
||||||
continue
|
continue
|
||||||
|
|
Loading…
Reference in New Issue