Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

Modified the django system test script to search for tests in the con…

…trib apps.

git-svn-id: http://code.djangoproject.com/svn/django/trunk@5296 bcc190cf-cafb-0310-a4f2-bffc1f526a37
  • Loading branch information...
commit c9aa4c71ac316e94beb97307502ae2acf8ef6aed 1 parent d43522b
Russell Keith-Magee authored
17  django/contrib/webdesign/tests.py
... ...
@@ -0,0 +1,17 @@
  1
+# -*- coding: utf-8 -*-
  2
+
  3
+r"""
  4
+>>> words(7)
  5
+'lorem ipsum dolor sit amet consectetur adipisicing'
  6
+
  7
+>>> paragraphs(1)
  8
+['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.']
  9
+
  10
+"""
  11
+
  12
+from django.contrib.webdesign.lorem_ipsum import *
  13
+import datetime
  14
+
  15
+if __name__ == '__main__':
  16
+    import doctest
  17
+    doctest.testmod()
14  tests/runtests.py
@@ -3,11 +3,15 @@
3 3
 import os, sys, traceback
4 4
 import unittest
5 5
 
  6
+import django.contrib as contrib
  7
+CONTRIB_DIR_NAME = 'django.contrib'
6 8
 MODEL_TESTS_DIR_NAME = 'modeltests'
7 9
 REGRESSION_TESTS_DIR_NAME = 'regressiontests'
  10
+
8 11
 TEST_DATABASE_NAME = 'django_test_db'
9 12
 TEST_TEMPLATE_DIR = 'templates'
10 13
 
  14
+CONTRIB_DIR = os.path.dirname(contrib.__file__)
11 15
 MODEL_TEST_DIR = os.path.join(os.path.dirname(__file__), MODEL_TESTS_DIR_NAME)
12 16
 REGRESSION_TEST_DIR = os.path.join(os.path.dirname(__file__), REGRESSION_TESTS_DIR_NAME)
13 17
 
@@ -24,7 +28,7 @@
24 28
 
25 29
 def get_test_models():
26 30
     models = []
27  
-    for loc, dirpath in (MODEL_TESTS_DIR_NAME, MODEL_TEST_DIR), (REGRESSION_TESTS_DIR_NAME, REGRESSION_TEST_DIR):
  31
+    for loc, dirpath in (MODEL_TESTS_DIR_NAME, MODEL_TEST_DIR), (REGRESSION_TESTS_DIR_NAME, REGRESSION_TEST_DIR), (CONTRIB_DIR_NAME, CONTRIB_DIR):
28 32
         for f in os.listdir(dirpath):
29 33
             if f.startswith('__init__') or f.startswith('.') or f.startswith('sql') or f.startswith('invalid'):
30 34
                 continue
@@ -33,7 +37,7 @@ def get_test_models():
33 37
 
34 38
 def get_invalid_models():
35 39
     models = []
36  
-    for loc, dirpath in (MODEL_TESTS_DIR_NAME, MODEL_TEST_DIR), (REGRESSION_TESTS_DIR_NAME, REGRESSION_TEST_DIR):
  40
+    for loc, dirpath in (MODEL_TESTS_DIR_NAME, MODEL_TEST_DIR), (REGRESSION_TESTS_DIR_NAME, REGRESSION_TEST_DIR), (CONTRIB_DIR_NAME, CONTRIB_DIR):
37 41
         for f in os.listdir(dirpath):
38 42
             if f.startswith('__init__') or f.startswith('.') or f.startswith('sql'):
39 43
                 continue
@@ -109,8 +113,10 @@ def django_tests(verbosity, tests_to_run):
109 113
                 if verbosity >= 1:
110 114
                     print "Importing model %s" % model_name
111 115
                 mod = load_app(model_label)
112  
-                settings.INSTALLED_APPS.append(model_label)
113  
-                test_models.append(mod)
  116
+                if mod:
  117
+                    if model_label not in settings.INSTALLED_APPS:
  118
+                        settings.INSTALLED_APPS.append(model_label)
  119
+                    test_models.append(mod)
114 120
         except Exception, e:
115 121
             sys.stderr.write("Error while importing %s:" % model_name + ''.join(traceback.format_exception(*sys.exc_info())[1:]))
116 122
             continue
0  webdesign/models.py b/django/contrib/webdesign/models.py
No changes.

0 notes on commit c9aa4c7

Please sign in to comment.
Something went wrong with that request. Please try again.