Exemple #1
0
    def __init__(self, build_id='default', distributed=False, worker=False,
                 multiprocess=False, xunit=False, xunit_output='./xunit/',
                 include='', exclude='', max_workers=None, start_dir=None,
                 loader=defaultTestLoader, base_cmd='unit2 $TEST', 
                 workspace=None, log_level=logging.DEBUG, *args, **kwargs):

        assert not (distributed and worker and multiprocess), "You cannot combine --distributed, --worker, and --multiprocess"
        
        self.build_id = build_id
        
        self.distributed = distributed
        self.worker = worker
        self.multiprocess = multiprocess

        self.xunit = xunit
        self.xunit_output = os.path.realpath(xunit_output)
        if include:
            self.include_testcases = [import_string(i) for i in include.split(',')]
        else:
            self.include_testcases = []
        if exclude:
            self.exclude_testcases = [import_string(i) for i in exclude.split(',')]
        else:
            self.exclude_testcases = []
        self.max_workers = max_workers
        self.start_dir = start_dir
        self.loader = loader
        self.logger = logging.getLogger('mule')
        self.logger.setLevel(log_level)
        
        self.base_cmd = base_cmd
        self.workspace = workspace
Exemple #2
0
    def __init__(self,
                 build_id='default',
                 distributed=False,
                 worker=False,
                 multiprocess=False,
                 xunit=False,
                 xunit_output='./xunit/',
                 include='',
                 exclude='',
                 max_workers=None,
                 start_dir=None,
                 loader=defaultTestLoader,
                 base_cmd='unit2 $TEST',
                 workspace=None,
                 log_level=logging.DEBUG,
                 *args,
                 **kwargs):

        assert not (
            distributed and worker and multiprocess
        ), "You cannot combine --distributed, --worker, and --multiprocess"

        self.build_id = build_id

        self.distributed = distributed
        self.worker = worker
        self.multiprocess = multiprocess

        self.xunit = xunit
        self.xunit_output = os.path.realpath(xunit_output)
        if include:
            self.include_testcases = [
                import_string(i) for i in include.split(',')
            ]
        else:
            self.include_testcases = []
        if exclude:
            self.exclude_testcases = [
                import_string(i) for i in exclude.split(',')
            ]
        else:
            self.exclude_testcases = []
        self.max_workers = max_workers
        self.start_dir = start_dir
        self.loader = loader
        self.logger = logging.getLogger('mule')
        self.logger.setLevel(log_level)

        self.base_cmd = base_cmd
        self.workspace = workspace
Exemple #3
0
def get_test_by_name(label, loader=defaultTestLoader):
    """Construct a test case with the specified label. Label should be of the
    form model.TestClass or model.TestClass.test_method. Returns an
    instantiated test or test suite corresponding to the label provided.
    """
    # TODO: Refactor this as the code sucks

    try:
        imp = import_string(label)
    except AttributeError:
        # XXX: Handle base_module.TestCase shortcut (assumption)
        module_name, class_name = label.rsplit('.', 1)
        imp = import_string(module_name)
        imp = import_string('%s.%s' % (get_test_module(imp).__name__, class_name))
    
    if isinstance(imp, types.ModuleType):
        return loader.loadTestsFromModule(imp)
    elif issubclass(imp, unittest.TestCase):
        return loader.loadTestsFromTestCase(imp)
    elif issubclass(imp.__class__, unittest.TestCase):
        return imp.__class__(imp.__name__)

    # If no tests were found, then we were given a bad test label.
    raise ValueError("Test label '%s' does not refer to a test" % label)
Exemple #4
0
                finally:
                    cursor.close()

                connection.close()
        else:
            bootstrap = True

        # Ensure we import all tests that could possibly be executed so that tables get created
        # and all signals get registered
        for app in get_apps():
            get_test_module(app)

            # Import the 'management' module within each installed app, to register
            # dispatcher events.
            try:
                import_string('%s.management' % app.__name__.rsplit('.', 1)[0])
            except (ImportError, AttributeError):
                pass

        # HACK: We need to kill post_syncdb receivers to stop them from sending when the databases
        #       arent fully ready.
        post_syncdb_receivers = signals.post_syncdb.receivers
        signals.post_syncdb.receivers = []

        if not bootstrap:
            old_names = []
            mirrors = []
            for alias in connections:
                connection = connections[alias]

                if connection.settings_dict['TEST_MIRROR']:
Exemple #5
0
                finally:
                    cursor.close()

                connection.close()
        else:
            bootstrap = True

        # Ensure we import all tests that could possibly be executed so that tables get created
        # and all signals get registered
        for app in get_apps():
            get_test_module(app)

            # Import the 'management' module within each installed app, to register
            # dispatcher events.
            try:
                import_string('%s.management' % app.__name__.rsplit('.', 1)[0])
            except (ImportError, AttributeError):
                pass

        # HACK: We need to kill post_syncdb receivers to stop them from sending when the databases
        #       arent fully ready.
        post_syncdb_receivers = signals.post_syncdb.receivers
        signals.post_syncdb.receivers = []

        if not bootstrap:
            old_names = []
            mirrors = []
            for alias in connections:
                connection = connections[alias]

                if connection.settings_dict['TEST_MIRROR']: