Ticket #11627: test_suite.3.diff

File test_suite.3.diff, 2.4 KB (added by Filip Gruszczyński, 15 years ago)

better patch

  • django/test/simple.py

     
    8080    """
    8181    parts = label.split('.')
    8282    if len(parts) < 2 or len(parts) > 3:
    83         raise ValueError("Test label '%s' should be of the form app.TestCase or app.TestCase.test_method" % label)
     83        raise ValueError("Test label '%s' should be of the form app.TestCase or app.suite or app.TestCase.test_method" % label)
    8484
    85     app_module = get_app(parts[0])
    86     TestClass = getattr(app_module, parts[1], None)
     85    module = get_app(parts[0])
     86    TestClass = getattr(module, parts[1], None)
    8787
    8888    # Couldn't find the test class in models.py; look in tests.py
    8989    if TestClass is None:
    90         test_module = get_tests(app_module)
    91         if test_module:
    92             TestClass = getattr(test_module, parts[1], None)
    93 
    94     if len(parts) == 2: # label is app.TestClass
     90        module = get_tests(module)
     91        if module:
     92            TestClass = getattr(module, parts[1], None)
     93    if len(parts) == 2: # label is app.TestClass or app.suite
    9594        try:
    96             return unittest.TestLoader().loadTestsFromTestCase(TestClass)
     95            return unittest.TestLoader().loadTestsFromName(parts[1], module)
    9796        except TypeError:
    9897            raise ValueError("Test label '%s' does not refer to a test class" % label)
    9998    else: # label is app.TestClass.test_method
  • django/test/testcases.py

     
    460460        transaction.rollback()
    461461        transaction.leave_transaction_management()
    462462        connection.close()
     463
     464
     465class TestSuite(unittest.TestSuite):
     466        pass
  • django/test/__init__.py

     
    33"""
    44
    55from django.test.client import Client
    6 from django.test.testcases import TestCase, TransactionTestCase
     6from django.test.testcases import TestCase, TransactionTestCase, TestSuite
  • tests/regressiontests/test_utils/models.py

     
     1
Back to Top