Django

Code

Changeset 348

Show
Ignore:
Timestamp:
07/29/05 17:35:54 (3 years ago)
Author:
adrian
Message:

Added tests.builddocs, which builds HTML documentation by introspecting the model unit tests

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • django/trunk/tests/runtests.py

    r342 r348  
    1717        'description': description, 
    1818    }) 
     19 
     20MODEL_DIR = os.path.join(os.path.dirname(__file__), APP_NAME, 'models') 
     21 
     22def get_test_models(): 
     23    return [f[:-3] for f in os.listdir(MODEL_DIR) if f.endswith('.py') and not f.startswith('__init__')] 
    1924 
    2025class DjangoDoctestRunner(doctest.DocTestRunner): 
     
    5257        settings.INSTALLED_APPS = (APP_NAME,) 
    5358 
    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. 
    5561        if settings.DATABASE_ENGINE == "sqlite3": 
    5662            global TEST_DATABASE_NAME 
    5763            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. 
    6168            cursor = db.cursor() 
    6269            try: 
     
    8491        management.init() 
    8592 
    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(): 
    9095            self.output(1, "%s model: Importing" % model_name) 
    9196            try: 
     
    107112            runner.run(dtest, clear_globs=True, out=sys.stdout.write) 
    108113 
    109         # Unless we're using SQLite, remove the test database, to clean up after 
    110         # 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 
    112117        # connected to it. 
    113118        if settings.DATABASE_ENGINE != "sqlite3": 
  • django/trunk/tests/testapp/models/lookup.py

    r339 r348  
    227. The lookup API 
    33 
     4This demonstrates features of the database API. 
    45""" 
    56