~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/selftest/__init__.py

  • Committer: Robert Collins
  • Date: 2005-10-11 07:52:29 UTC
  • mto: This revision was merged to the branch mainline in revision 1444.
  • Revision ID: robertc@lifelesslap.robertcollins.net-20051011075229-e1a1429e0b59f80f
nuke --pattern to selftest, replace with regexp.search calls.

Show diffs side-by-side

added added

removed removed

Lines of Context:
398
398
    result = TestUtil.TestSuite()
399
399
    filter_re = re.compile(pattern)
400
400
    for test in iter_suite_tests(suite):
401
 
        if filter_re.match(test.id()):
 
401
        if filter_re.search(test.id()):
402
402
            result.addTest(test)
403
403
    return result
404
404
 
405
405
 
406
 
def filter_suite_by_names(suite, wanted_names):
407
 
    """Return a new suite containing only selected tests.
408
 
    
409
 
    Names are considered to match if any name is a substring of the 
410
 
    fully-qualified test id (i.e. the class ."""
411
 
    result = TestSuite()
412
 
    for test in iter_suite_tests(suite):
413
 
        this_id = test.id()
414
 
        for p in wanted_names:
415
 
            if this_id.find(p) != -1:
416
 
                result.addTest(test)
417
 
    return result
418
 
 
419
 
 
420
 
def run_suite(suite, name='test', verbose=False, pattern=".*", testnames=None):
 
406
def run_suite(suite, name='test', verbose=False, pattern=".*"):
421
407
    TestCaseInTempDir._TEST_NAME = name
422
408
    if verbose:
423
409
        verbosity = 2
426
412
    runner = TextTestRunner(stream=sys.stdout,
427
413
                            descriptions=0,
428
414
                            verbosity=verbosity)
429
 
    if testnames:
430
 
        suite = filter_suite_by_names(suite, testnames)
431
415
    if pattern != '.*':
432
416
        suite = filter_suite_by_re(suite, pattern)
433
417
    result = runner.run(suite)
442
426
    return result.wasSuccessful()
443
427
 
444
428
 
445
 
def selftest(verbose=False, pattern=".*", testnames=None):
 
429
def selftest(verbose=False, pattern=".*"):
446
430
    """Run the whole test suite under the enhanced runner"""
447
 
    return run_suite(test_suite(), 'testbzr', verbose=verbose, pattern=pattern,
448
 
                     testnames=testnames)
 
431
    return run_suite(test_suite(), 'testbzr', verbose=verbose, pattern=pattern)
449
432
 
450
433
 
451
434
def test_suite():