Changeset 348
- Timestamp:
- 07/29/05 17:35:54 (3 years ago)
- Files:
-
- django/trunk/tests/builddocs.py (added)
- django/trunk/tests/runtests.py (modified) (4 diffs)
- django/trunk/tests/testapp/models/lookup.py (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
django/trunk/tests/runtests.py
r342 r348 17 17 'description': description, 18 18 }) 19 20 MODEL_DIR = os.path.join(os.path.dirname(__file__), APP_NAME, 'models') 21 22 def get_test_models(): 23 return [f[:-3] for f in os.listdir(MODEL_DIR) if f.endswith('.py') and not f.startswith('__init__')] 19 24 20 25 class DjangoDoctestRunner(doctest.DocTestRunner): … … 52 57 settings.INSTALLED_APPS = (APP_NAME,) 53 58 54 # If we're using SQLite, it's more convient to test against an in-memory database 59 # If we're using SQLite, it's more convenient to test against an 60 # in-memory database. 55 61 if settings.DATABASE_ENGINE == "sqlite3": 56 62 global TEST_DATABASE_NAME 57 63 TEST_DATABASE_NAME = ":memory:" 58 else: 59 # Create the test database and connect to it. We need autocommit() because 60 # PostgreSQL doesn't allow CREATE DATABASE statements within transactions. 64 else: 65 # Create the test database and connect to it. We need autocommit() 66 # because PostgreSQL doesn't allow CREATE DATABASE statements 67 # within transactions. 61 68 cursor = db.cursor() 62 69 try: … … 84 91 management.init() 85 92 86 # Run the tests for each model within APP_NAME/models. 87 model_dir = os.path.join(os.path.dirname(__file__), APP_NAME, 'models') 88 test_models = [f[:-3] for f in os.listdir(model_dir) if f.endswith('.py') and not f.startswith('__init__')] 89 for model_name in test_models: 93 # Run the tests for each test model. 94 for model_name in get_test_models(): 90 95 self.output(1, "%s model: Importing" % model_name) 91 96 try: … … 107 112 runner.run(dtest, clear_globs=True, out=sys.stdout.write) 108 113 109 # Unless we're using SQLite, remove the test database ,to clean up after110 # ourselves. Connect to the previous database (not the test database) 111 # to do so, because it's not allowed to delete a database while being 114 # Unless we're using SQLite, remove the test database to clean up after 115 # ourselves. Connect to the previous database (not the test database) 116 # to do so, because it's not allowed to delete a database while being 112 117 # connected to it. 113 118 if settings.DATABASE_ENGINE != "sqlite3": django/trunk/tests/testapp/models/lookup.py
r339 r348 2 2 7. The lookup API 3 3 4 This demonstrates features of the database API. 4 5 """ 5 6
