# -*- coding: utf-8 -*-

from codespeed.tests.tests import *
from codespeed.tests.tests_api import *


@@ -22,81 +22,3308 @@
 *-%0A%0A
-from codespeed.tests.tests import *%0Afrom codespeed.tests.tests_api import *
+import os%0Aimport re%0Aimport unittest%0A%0Afrom django.utils.importlib import import_module%0Afrom django.test._doctest import DocTestSuite%0Afrom django.test.testcases import DocTestRunner%0Afrom django.test.simple import doctestOutputChecker%0A%0AloadTestsFromModule = unittest.defaultTestLoader.loadTestsFromModule%0A%0ADEFAULT_TESTFILE_PATTERN = re.compile(r'%5E%5Ba-zA-Z0-9%5D.*%5C.py')%0A%0Adef get_suite(*names, **kwargs):%0A    '''Creates (or updates) a %60%60TestSuite%60%60 consisting of the tests under one or%0A    more modules.%0A%0A    See http://djangosnippets.org/snippets/1972/%0A%0A    This is useful for splitting a Django %60%60tests.py%60%60 module into multiple test%0A    modules under a %60%60tests%60%60 directory without having to import them manually%0A    in %60%60tests/__init__.py%60%60. All you have to write in %60%60tests/__init__.py%60%60 is::%0A%0A        from ... import get_suite%0A%0A        # django.test looks for a function named suite that returns a TestSuite%0A        suite = lambda: get_suite(__name__)%0A%0A    This creates a suite consisting of all %60%60TestCase%60%60 instances defined under%0A    any %60%60test_.*py%60%60 module under %60%60tests%60%60.%0A%0A    :param names: One or more module or package names to be added in the suite.%0A        For module names, the respective module's TestCases are loaded. For package%0A        names, the TestCases of all modules in the package directory satisfying%0A        %60%60is_test_module%60%60 are loaded.%0A    :keyword is_test_module: Determines whether a file is a test module. It can%0A        be a callable %60%60f(filename)%60%60 or a regular expression (string or compiled)%0A        that test module file names should %60%60match()%60%60.%0A    :keyword suite: If given, update this suite instead of creating a new one.%0A    '''%0A%0A    suite = kwargs.get('suite') or unittest.TestSuite()%0A    # determine is_test_module%0A    is_test_module = kwargs.get('is_test_module', DEFAULT_TESTFILE_PATTERN)%0A    if isinstance(is_test_module, basestring): # look for exact match%0A        is_test_module = re.compile(is_test_module + '$').match%0A    elif hasattr(is_test_module, 'match'):%0A        is_test_module = is_test_module.match%0A    # determine the test modules to be added in the suite and import them%0A    modules = set()%0A    for name in names:%0A        package = import_module(name)%0A        # if it's a single module just add it%0A        if os.path.splitext(os.path.basename(package.__file__))%5B0%5D != '__init__':%0A            modules.add(package)%0A        else: # otherwise it's a package; add all test modules under the dir%0A            modules.update(%0A                import_module('.' + os.path.splitext(f)%5B0%5D, package=name)%0A                for f in os.listdir(os.path.dirname(package.__file__))%0A                if is_test_module(f))%0A    # add the modules to the suite%0A    for module in modules:%0A        # copied from django.test.simple.build_suite%0A        if hasattr(module, 'suite'):%0A            # if module has a suite() method, use it%0A            suite.addTest(module.suite())%0A        else: # otherwise build the test suite ourselves.%0A            suite.addTest(loadTestsFromModule(module))%0A            try:%0A                suite.addTest(DocTestSuite(module, runner=DocTestRunner,%0A                                           checker=doctestOutputChecker))%0A            except ValueError: # No doc tests%0A                pass%0A    return suite%0A%0Asuite = lambda: get_suite(__name__)
 %0A%0A

Add tests from any file in codespeed/tests automatically