Changeset 228

Show
Ignore:
Timestamp:
08/06/07 23:37:36 (1 year ago)
Author:
johnbywater
Message:

Merged profiletest script into test script as --profile option.

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/bin/domainmodel-test

    r219 r228  
    99import unittest 
    1010from optparse import OptionParser 
     11import profile 
    1112 
    1213os.environ['DJANGO_SETTINGS_MODULE'] = 'dm.django.settings.main' 
     
    3031        help='Path to configuration file. If not provided please ensure relevant environment variable is set.' 
    3132        ) 
    32      
     33    parser.add_option('-p', '--profile', 
     34        action='store_true', dest='profile', default=False, 
     35        help='Profile the performance of a test suite') 
     36 
    3337    (options, args) = parser.parse_args() 
    3438    if options.config: 
     
    5559         
    5660    testRunner = unittest.TextTestRunner(verbosity=options.level) 
    57     result = testRunner.run(testSuite) 
     61    if options.profile: 
     62        code = "result = testRunner.run(testSuite)" 
     63        profile.run(code) 
     64    else: 
     65        result = testRunner.run(testSuite) 
     66 
    5867    if not result.wasSuccessful(): 
    5968        sys.exit(1)