示例#1
0
def load_tests(standard_tests, module, loader):
    supported_scenarios = []
    unsupported_scenarios = []
    for test_name, scenario_info in all_repository_format_scenarios():
        format = scenario_info['repository_format']
        # For remote repositories, we test both with, and without a backing chk
        # capable format: change the format we use to create the repo to direct
        # formats, and then the overridden make_repository in
        # TestCaseWithRepositoryCHK will give a re-opened RemoteRepository
        # with the chosen backing format.
        if isinstance(format, remote.RemoteRepositoryFormat):
            with_support = dict(scenario_info)
            with_support['repository_format'] = RepositoryFormat2a()
            supported_scenarios.append(
                (test_name + "(Supported)", with_support))
            no_support = dict(scenario_info)
            no_support['repository_format'] = RepositoryFormatKnitPack5()
            unsupported_scenarios.append(
                (test_name + "(Not Supported)", no_support))
        elif format.supports_chks:
            supported_scenarios.append((test_name, scenario_info))
        else:
            unsupported_scenarios.append((test_name, scenario_info))
    result = loader.suiteClass()
    supported_tests = loader.loadTestsFromModuleNames(
        ['bzrlib.tests.per_repository_chk.test_supported'])
    unsupported_tests = loader.loadTestsFromModuleNames(
        ['bzrlib.tests.per_repository_chk.test_unsupported'])
    multiply_tests(supported_tests, supported_scenarios, result)
    multiply_tests(unsupported_tests, unsupported_scenarios, result)
    return result
示例#2
0
def load_tests(standard_tests, module, loader):
    supported_scenarios = []
    unsupported_scenarios = []
    for test_name, scenario_info in all_repository_format_scenarios():
        format = scenario_info['repository_format']
        # For remote repositories, we test both with, and without a backing chk
        # capable format: change the format we use to create the repo to direct
        # formats, and then the overridden make_repository in
        # TestCaseWithRepositoryCHK will give a re-opened RemoteRepository
        # with the chosen backing format.
        if isinstance(format, remote.RemoteRepositoryFormat):
            with_support = dict(scenario_info)
            with_support['repository_format'] = RepositoryFormat2a()
            supported_scenarios.append((test_name + "(Supported)", with_support))
            no_support = dict(scenario_info)
            no_support['repository_format'] = RepositoryFormatKnitPack5()
            unsupported_scenarios.append((test_name + "(Not Supported)", no_support))
        elif format.supports_chks:
            supported_scenarios.append((test_name, scenario_info))
        else:
            unsupported_scenarios.append((test_name, scenario_info))
    result = loader.suiteClass()
    supported_tests = loader.loadTestsFromModuleNames([
        'bzrlib.tests.per_repository_chk.test_supported'])
    unsupported_tests = loader.loadTestsFromModuleNames([
        'bzrlib.tests.per_repository_chk.test_unsupported'])
    multiply_tests(supported_tests, supported_scenarios, result)
    multiply_tests(unsupported_tests, unsupported_scenarios, result)
    return result
示例#3
0
 def test_multiply_tests(self):
     loader = TestLoader()
     suite = loader.suiteClass()
     multiply_tests(
         self,
         vary_by_color(),
         suite)
     self.assertEquals(
         ['blue', 'green', 'red'],
         get_generated_test_attributes(suite, 'color'))
示例#4
0
def load_tests(standard_tests, module, loader):
    result = loader.suiteClass()
    per_vcs_mod_names = [
        'branch',
        'repository',
        ]
    sub_tests = loader.loadTestsFromModuleNames(
        ['bzrlib.tests.per_foreign_vcs.test_' + name
         for name in per_vcs_mod_names])
    tests.multiply_tests(sub_tests, vcs_scenarios(), result)
    return result
示例#5
0
def load_tests(standard_tests, module, loader):
    result = loader.suiteClass()
    per_vcs_mod_names = [
        'branch',
        'repository',
    ]
    sub_tests = loader.loadTestsFromModuleNames([
        'bzrlib.tests.per_foreign_vcs.test_' + name
        for name in per_vcs_mod_names
    ])
    tests.multiply_tests(sub_tests, vcs_scenarios(), result)
    return result
示例#6
0
def load_tests(standard_tests, module, loader):
    prefix = 'bzrlib.tests.per_repository.'
    test_repository_modules = [
        'test_add_fallback_repository',
        'test_break_lock',
        'test_check',
        'test_commit_builder',
        'test_fetch',
        'test_file_graph',
        'test_get_parent_map',
        'test_has_same_location',
        'test_has_revisions',
        'test_locking',
        'test_pack',
        'test_reconcile',
        'test_refresh_data',
        'test_repository',
        'test_revision',
        'test_signatures',
        'test_statistics',
        'test_write_group',
        ]
    # Parameterize per_repository test modules by format.
    submod_tests = loader.loadTestsFromModuleNames(
        [prefix + module_name for module_name in test_repository_modules])
    format_scenarios = all_repository_format_scenarios()
    return multiply_tests(submod_tests, format_scenarios, standard_tests)
示例#7
0
def multiply_tests_by_their_scenarios(some_tests, into_suite):
    """Multiply the tests in the given suite by their declared scenarios.

    Each test must have a 'scenarios' attribute which is a list of 
    (name, params) pairs.

    :param some_tests: TestSuite or Test.
    :param into_suite: A TestSuite into which the resulting tests will be
        inserted.
    """
    for test in iter_suite_tests(some_tests):
        scenarios = getattr(test, 'scenarios', None)
        if scenarios is None:
            into_suite.addTest(test)
        else:
            multiply_tests(test, test.scenarios, into_suite)
示例#8
0
def load_tests(standard_tests, module, loader):
    prefix = 'bzrlib.tests.per_repository.'
    test_repository_modules = [
        'test_add_fallback_repository',
        'test_break_lock',
        'test_check',
        'test_commit_builder',
        'test_fetch',
        'test_file_graph',
        'test_get_parent_map',
        'test_has_same_location',
        'test_has_revisions',
        'test_locking',
        'test_pack',
        'test_reconcile',
        'test_refresh_data',
        'test_repository',
        'test_revision',
        'test_signatures',
        'test_statistics',
        'test_write_group',
        ]
    # Parameterize per_repository test modules by format.
    submod_tests = loader.loadTestsFromModuleNames(
        [prefix + module_name for module_name in test_repository_modules])
    format_scenarios = all_repository_format_scenarios()
    return multiply_tests(submod_tests, format_scenarios, standard_tests)
示例#9
0
def load_tests(basic_tests, module, loader):
    """Generate suite containing all parameterized tests"""
    modules_to_test = [
        'bzrlib.tests.per_inventory.basics',
    ]
    from bzrlib.inventory import Inventory, CHKInventory

    def inv_to_chk_inv(test, inv):
        """CHKInventory needs a backing VF, so we create one."""
        factory = groupcompress.make_pack_factory(True, True, 1)
        trans = test.get_transport('chk-inv')
        trans.ensure_base()
        vf = factory(trans)
        # We intentionally use a non-standard maximum_size, so that we are more
        # likely to trigger splits, and get increased test coverage.
        chk_inv = CHKInventory.from_inventory(vf,
                                              inv,
                                              maximum_size=100,
                                              search_key_name='hash-255-way')
        return chk_inv

    scenarios = [('Inventory', {
        '_inventory_class': Inventory,
        '_inv_to_test_inv': lambda test, inv: inv
    }),
                 ('CHKInventory', {
                     '_inventory_class': CHKInventory,
                     '_inv_to_test_inv': inv_to_chk_inv,
                 })]
    # add the tests for the sub modules
    return tests.multiply_tests(
        loader.loadTestsFromModuleNames(modules_to_test), scenarios,
        basic_tests)
示例#10
0
def load_tests(standard_tests, module, loader):
    per_tree_mod_names = [
        'annotate_iter',
        'export',
        'get_file_mtime',
        'get_file_with_stat',
        'get_root_id',
        'get_symlink_target',
        'ids',
        'inv',
        'iter_search_rules',
        'is_executable',
        'list_files',
        'locking',
        'path_content_summary',
        'revision_tree',
        'test_trees',
        'tree',
        'walkdirs',
        ]
    submod_tests = loader.loadTestsFromModuleNames(
        ['bzrlib.tests.per_tree.test_' + name
         for name in per_tree_mod_names])
    scenarios = make_scenarios(
        tests.default_transport,
        # None here will cause a readonly decorator to be created
        # by the TestCaseWithTransport.get_readonly_transport method.
        None,
        format_registry._get_all())
    # add the tests for the sub modules
    return tests.multiply_tests(submod_tests, scenarios, standard_tests)
示例#11
0
def load_tests(standard_tests, module, loader):
    per_branch_mod_names = [
        'branch',
        'break_lock',
        'check',
        'config',
        'create_checkout',
        'create_clone',
        'commit',
        'dotted_revno_to_revision_id',
        'get_revision_id_to_revno_map',
        'hooks',
        'http',
        'iter_merge_sorted_revisions',
        'last_revision_info',
        'locking',
        'parent',
        'permissions',
        'pull',
        'push',
        'reconcile',
        'revision_id_to_dotted_revno',
        'revision_id_to_revno',
        'sprout',
        'stacking',
        'tags',
        'uncommit',
        'update',
        ]
    sub_tests = loader.loadTestsFromModuleNames(
        ['bzrlib.tests.per_branch.test_' + name
         for name in per_branch_mod_names])
    return tests.multiply_tests(sub_tests, branch_scenarios(), standard_tests)
示例#12
0
def test_suite():
    tests = unittest.TestLoader().loadTestsFromName(__name__)
    scenarios = [
        ('ftp', {'server_factory': FTPServer,
                 # XXX: In an ideal world, this would be in the UnitTests
                 # layer. Let's get one step closer to that ideal world.
                 'layer': ZopelessDatabaseLayer}),
        ('sftp', {'server_factory': SFTPServer,
                  'layer': ZopelessAppServerLayer}),
        ]
    suite = unittest.TestSuite()
    multiply_tests(tests, scenarios, suite)
    # SFTP doesn't have the concept of the server changing directories, since
    # clients will only send absolute paths, so drop that test.
    return exclude_tests_by_condition(
        suite, condition_id_re(r'test_change_directory.*\(sftp\)$'))
示例#13
0
def load_tests(basic_tests, module, loader):
    """Generate suite containing all parameterized tests"""
    modules_to_test = [
        'bzrlib.tests.per_inventory.basics',
        ]
    from bzrlib.inventory import Inventory, CHKInventory

    def inv_to_chk_inv(test, inv):
        """CHKInventory needs a backing VF, so we create one."""
        factory = groupcompress.make_pack_factory(True, True, 1)
        trans = test.get_transport('chk-inv')
        trans.ensure_base()
        vf = factory(trans)
        # We intentionally use a non-standard maximum_size, so that we are more
        # likely to trigger splits, and get increased test coverage.
        chk_inv = CHKInventory.from_inventory(vf, inv,
                        maximum_size=100,
                        search_key_name='hash-255-way')
        return chk_inv
    scenarios = [('Inventory', {'_inventory_class': Inventory,
                                '_inv_to_test_inv': lambda test, inv: inv
                               }),
                 ('CHKInventory', {'_inventory_class': CHKInventory,
                                   '_inv_to_test_inv': inv_to_chk_inv,
                                  })]
    # add the tests for the sub modules
    return tests.multiply_tests(
        loader.loadTestsFromModuleNames(modules_to_test),
        scenarios, basic_tests)
示例#14
0
def load_tests(standard_tests, module, loader):
    test_per_controldir = [
        'bzrlib.tests.per_controldir.test_controldir',
        'bzrlib.tests.per_controldir.test_format',
        'bzrlib.tests.per_controldir.test_push',
        ]
    submod_tests = loader.loadTestsFromModuleNames(test_per_controldir)
    formats = ControlDirFormat.known_formats()
    scenarios = make_scenarios(
        default_transport,
        None,
        # None here will cause a readonly decorator to be created
        # by the TestCaseWithTransport.get_readonly_transport method.
        None,
        formats)
    # This will always add scenarios using the smart server.
    from bzrlib.remote import RemoteBzrDirFormat
    # test the remote server behaviour when backed with a MemoryTransport
    # Once for the current version
    scenarios.extend(make_scenarios(
        memory.MemoryServer,
        test_server.SmartTCPServer_for_testing,
        test_server.ReadonlySmartTCPServer_for_testing,
        [(RemoteBzrDirFormat())],
        name_suffix='-default'))
    # And once with < 1.6 - the 'v2' protocol.
    scenarios.extend(make_scenarios(
        memory.MemoryServer,
        test_server.SmartTCPServer_for_testing_v2_only,
        test_server.ReadonlySmartTCPServer_for_testing_v2_only,
        [(RemoteBzrDirFormat())],
        name_suffix='-v2'))
    # add the tests for the sub modules
    return multiply_tests(submod_tests, scenarios, standard_tests)
示例#15
0
def load_tests(standard_tests, module, loader):
    """Multiply tests for tranport implementations."""
    result = loader.suiteClass()
    scenarios = [(name, {
        'merge_type': merger
    }) for name, merger in _mod_merge.merge_type_registry.items()]
    return multiply_tests(standard_tests, scenarios, result)
示例#16
0
def load_tests(standard_tests, module, loader):
    """Multiply tests for tranport implementations."""
    result = loader.suiteClass()
    scenarios = [
        (name, {'merge_type': merger})
        for name, merger in _mod_merge.merge_type_registry.items()]
    return multiply_tests(standard_tests, scenarios, result)
示例#17
0
def load_tests(standard_tests, module, loader):
    result = loader.suiteClass()

    tree_tests, remaining_tests = tests.split_suite_by_condition(
        standard_tests, tests.condition_isinstance((TestTreeWidget, )))
    tests.multiply_tests(tree_tests, tree_scenarios, result)

    filter_tests, remaining_tests = tests.split_suite_by_condition(
        remaining_tests,
        tests.condition_isinstance((TestTreeFilterProxyModel, )))
    tests.multiply_tests(filter_tests, filter_scenarios, result)

    # No parametrization for the remaining tests
    result.addTests(remaining_tests)

    return result
示例#18
0
def multiply_tests_by_their_scenarios(some_tests, into_suite):
    """Multiply the tests in the given suite by their declared scenarios.

    Each test must have a 'scenarios' attribute which is a list of 
    (name, params) pairs.

    :param some_tests: TestSuite or Test.
    :param into_suite: A TestSuite into which the resulting tests will be
        inserted.
    """
    for test in iter_suite_tests(some_tests):
        scenarios = getattr(test, 'scenarios', None)
        if scenarios is None:
            into_suite.addTest(test)
        else:
            multiply_tests(test, test.scenarios, into_suite)
示例#19
0
def load_tests(standard_tests, module, loader):
    per_branch_mod_names = [
        'branch',
        'break_lock',
        'check',
        'config',
        'create_checkout',
        'create_clone',
        'commit',
        'dotted_revno_to_revision_id',
        'get_revision_id_to_revno_map',
        'hooks',
        'http',
        'iter_merge_sorted_revisions',
        'last_revision_info',
        'locking',
        'parent',
        'permissions',
        'pull',
        'push',
        'reconcile',
        'revision_id_to_dotted_revno',
        'revision_id_to_revno',
        'sprout',
        'stacking',
        'tags',
        'uncommit',
        'update',
    ]
    sub_tests = loader.loadTestsFromModuleNames([
        'bzrlib.tests.per_branch.test_' + name for name in per_branch_mod_names
    ])
    return tests.multiply_tests(sub_tests, branch_scenarios(), standard_tests)
示例#20
0
def load_tests(standard_tests, module, loader):
    test_per_controldir = [
        'bzrlib.tests.per_controldir.test_controldir',
        'bzrlib.tests.per_controldir.test_format',
        'bzrlib.tests.per_controldir.test_push',
    ]
    submod_tests = loader.loadTestsFromModuleNames(test_per_controldir)
    formats = ControlDirFormat.known_formats()
    scenarios = make_scenarios(
        default_transport,
        None,
        # None here will cause a readonly decorator to be created
        # by the TestCaseWithTransport.get_readonly_transport method.
        None,
        formats)
    # This will always add scenarios using the smart server.
    from bzrlib.remote import RemoteBzrDirFormat
    # test the remote server behaviour when backed with a MemoryTransport
    # Once for the current version
    scenarios.extend(
        make_scenarios(memory.MemoryServer,
                       test_server.SmartTCPServer_for_testing,
                       test_server.ReadonlySmartTCPServer_for_testing,
                       [(RemoteBzrDirFormat())],
                       name_suffix='-default'))
    # And once with < 1.6 - the 'v2' protocol.
    scenarios.extend(
        make_scenarios(memory.MemoryServer,
                       test_server.SmartTCPServer_for_testing_v2_only,
                       test_server.ReadonlySmartTCPServer_for_testing_v2_only,
                       [(RemoteBzrDirFormat())],
                       name_suffix='-v2'))
    # add the tests for the sub modules
    return multiply_tests(submod_tests, scenarios, standard_tests)
示例#21
0
def load_tests(standard_tests, module, loader):
    result = loader.suiteClass()
    t_tests, remaining_tests = tests.split_suite_by_condition(
        standard_tests, tests.condition_isinstance((TestXMLRPCTransport, )))
    transport_scenarios = [
        ('http', dict(server_class=PreCannedHTTPServer, )),
    ]
    if features.HTTPSServerFeature.available():
        transport_scenarios.append(
            ('https', dict(server_class=PreCannedHTTPSServer, )), )
    tests.multiply_tests(t_tests, transport_scenarios, result)

    # No parametrization for the remaining tests
    result.addTests(remaining_tests)

    return result
示例#22
0
def load_tests(standard_tests, module, loader):
    per_tree_mod_names = [
        'annotate_iter',
        'export',
        'get_file_mtime',
        'get_file_with_stat',
        'get_root_id',
        'get_symlink_target',
        'ids',
        'inv',
        'iter_search_rules',
        'is_executable',
        'list_files',
        'locking',
        'path_content_summary',
        'revision_tree',
        'test_trees',
        'tree',
        'walkdirs',
    ]
    submod_tests = loader.loadTestsFromModuleNames(
        ['bzrlib.tests.per_tree.test_' + name for name in per_tree_mod_names])
    scenarios = make_scenarios(
        tests.default_transport,
        # None here will cause a readonly decorator to be created
        # by the TestCaseWithTransport.get_readonly_transport method.
        None,
        format_registry._get_all())
    # add the tests for the sub modules
    return tests.multiply_tests(submod_tests, scenarios, standard_tests)
示例#23
0
def load_tests(basic_tests, module, loader):
    """Parametrize the tests of get_branch_stacked_on_url by branch format."""
    result = loader.suiteClass()

    get_branch_stacked_on_url_tests = loader.loadTestsFromTestCase(
        TestGetBranchStackedOnURL)
    scenarios = [scenario for scenario in branch_scenarios()
                 if scenario[0] not in (
                     'BranchReferenceFormat', 'GitBranchFormat',
                     'SvnBranchFormat')]
    multiply_tests(get_branch_stacked_on_url_tests, scenarios, result)

    result.addTests(loader.loadTestsFromTestCase(TestIsBranchStackable))
    result.addTests(loader.loadTestsFromTestCase(TestDenyingServer))
    result.addTests(loader.loadTestsFromTestCase(TestExceptionLoggingHooks))
    result.addTests(loader.loadTestsFromTestCase(TestGetVfsFormatClasses))
    return result
示例#24
0
def load_tests(standard_tests, module, loader):
    submod_tests = loader.loadTestsFromModuleNames([
        'bzrlib.tests.per_lock.test_lock',
        'bzrlib.tests.per_lock.test_temporary_write_lock',
    ])
    scenarios = make_scenarios(lock._lock_classes)
    # add the tests for the sub modules
    return tests.multiply_tests(submod_tests, scenarios, standard_tests)
示例#25
0
def load_tests(standard_tests, module, loader):
    submod_tests = loader.loadTestsFromModuleNames([
        'bzrlib.tests.per_lock.test_lock',
        'bzrlib.tests.per_lock.test_temporary_write_lock',
        ])
    scenarios = make_scenarios(lock._lock_classes)
    # add the tests for the sub modules
    return tests.multiply_tests(submod_tests, scenarios,
        standard_tests)
示例#26
0
def load_tests(basic_tests, module, loader):
    """Parametrize the tests of get_branch_stacked_on_url by branch format."""
    result = loader.suiteClass()

    get_branch_stacked_on_url_tests = loader.loadTestsFromTestCase(
        TestGetBranchStackedOnURL)
    scenarios = [
        scenario for scenario in branch_scenarios()
        if scenario[0] not in ('BranchReferenceFormat', 'GitBranchFormat',
                               'SvnBranchFormat')
    ]
    multiply_tests(get_branch_stacked_on_url_tests, scenarios, result)

    result.addTests(loader.loadTestsFromTestCase(TestIsBranchStackable))
    result.addTests(loader.loadTestsFromTestCase(TestDenyingServer))
    result.addTests(loader.loadTestsFromTestCase(TestExceptionLoggingHooks))
    result.addTests(loader.loadTestsFromTestCase(TestGetVfsFormatClasses))
    return result
示例#27
0
def load_tests(standard_tests, module, loader):
    default_tree_format = WorkingTreeFormat3()
    submod_tests = loader.loadTestsFromModuleNames([
        'bzrlib.tests.per_intertree.test_compare',
        'bzrlib.tests.per_intertree.test_file_content_matches',
    ])
    test_intertree_permutations = [
        # test InterTree with two default-format working trees.
        (InterTree.__name__, InterTree, default_tree_format,
         default_tree_format, return_provided_trees)
    ]
    for optimiser in InterTree._optimisers:
        if optimiser is revisiontree.InterCHKRevisionTree:
            # XXX: we shouldn't use an Intertree object to detect inventories
            # -- vila 20090311
            chk_tree_format = WorkingTreeFormat4()
            chk_tree_format._get_matchingbzrdir = \
                lambda:bzrlib.controldir.format_registry.make_bzrdir('2a')
            test_intertree_permutations.append(
                (InterTree.__name__ + "(CHKInventory)", InterTree,
                 chk_tree_format, chk_tree_format,
                 mutable_trees_to_revision_trees))
        elif optimiser is bzrlib.workingtree_4.InterDirStateTree:
            # Its a little ugly to be conditional here, but less so than having
            # the optimiser listed twice.
            # Add once, compiled version
            test_intertree_permutations.append(
                (optimiser.__name__ + "(C)", optimiser,
                 optimiser._matching_from_tree_format,
                 optimiser._matching_to_tree_format,
                 optimiser.make_source_parent_tree_compiled_dirstate))
            # python version
            test_intertree_permutations.append(
                (optimiser.__name__ + "(PY)", optimiser,
                 optimiser._matching_from_tree_format,
                 optimiser._matching_to_tree_format,
                 optimiser.make_source_parent_tree_python_dirstate))
        elif (optimiser._matching_from_tree_format is not None
              and optimiser._matching_to_tree_format is not None):
            test_intertree_permutations.append(
                (optimiser.__name__, optimiser,
                 optimiser._matching_from_tree_format,
                 optimiser._matching_to_tree_format,
                 optimiser._test_mutable_trees_to_test_trees))
    # PreviewTree does not have an InterTree optimiser class.
    test_intertree_permutations.append(
        (InterTree.__name__ + "(PreviewTree)", InterTree, default_tree_format,
         default_tree_format, mutable_trees_to_preview_trees))
    scenarios = make_scenarios(
        default_transport,
        # None here will cause a readonly decorator to be created
        # by the TestCaseWithTransport.get_readonly_transport method.
        None,
        test_intertree_permutations)
    # add the tests for the sub modules to the standard tests.
    return multiply_tests(submod_tests, scenarios, standard_tests)
示例#28
0
def load_tests(standard_tests, module, loader):
    submod_tests = loader.loadTestsFromModuleNames([
        'bzrlib.tests.per_interbranch.test_fetch',
        'bzrlib.tests.per_interbranch.test_get',
        'bzrlib.tests.per_interbranch.test_copy_content_into',
        'bzrlib.tests.per_interbranch.test_pull',
        'bzrlib.tests.per_interbranch.test_push',
        ])
    scenarios = make_scenarios(default_test_list())
    return multiply_tests(submod_tests, scenarios, standard_tests)
示例#29
0
def load_tests(standard_tests, module, loader):
    result = loader.suiteClass()
    t_tests, remaining_tests = tests.split_suite_by_condition(
        standard_tests, tests.condition_isinstance((
                TestXMLRPCTransport,
                )))
    transport_scenarios = [
        ('http', dict(server_class=PreCannedHTTPServer,)),
        ]
    if features.HTTPSServerFeature.available():
        transport_scenarios.append(
            ('https', dict(server_class=PreCannedHTTPSServer,)),
            )
    tests.multiply_tests(t_tests, transport_scenarios, result)

    # No parametrization for the remaining tests
    result.addTests(remaining_tests)

    return result
示例#30
0
def load_tests(standard_tests, module, loader):
    submod_tests = loader.loadTestsFromModuleNames([
        'bzrlib.tests.per_interbranch.test_fetch',
        'bzrlib.tests.per_interbranch.test_get',
        'bzrlib.tests.per_interbranch.test_copy_content_into',
        'bzrlib.tests.per_interbranch.test_pull',
        'bzrlib.tests.per_interbranch.test_push',
        ])
    scenarios = make_scenarios(default_test_list())
    return multiply_tests(submod_tests, scenarios, standard_tests)
示例#31
0
def load_tests(standard_tests, module, loader):
    test_names = [
        'add_reference',
        'add',
        'annotate_iter',
        'basis_inventory',
        'basis_tree',
        'break_lock',
        'changes_from',
        'check',
        'check_state',
        'content_filters',
        'commit',
        'eol_conversion',
        'executable',
        'flush',
        'get_file_mtime',
        'get_parent_ids',
        'inv',
        'is_control_filename',
        'is_ignored',
        'locking',
        'merge_from_branch',
        'mkdir',
        'move',
        'nested_specifics',
        'parents',
        'paths2ids',
        'pull',
        'put_file',
        'readonly',
        'read_working_inventory',
        'remove',
        'rename_one',
        'revision_tree',
        'set_root_id',
        'smart_add',
        'symlinks',
        'uncommit',
        'unversion',
        'views',
        'walkdirs',
        'workingtree',
        ]
    test_workingtree_implementations = [
        'bzrlib.tests.per_workingtree.test_' + name for
        name in test_names]

    scenarios = wt_scenarios()

    # add the tests for the sub modules
    return tests.multiply_tests(
        loader.loadTestsFromModuleNames(test_workingtree_implementations),
        scenarios, standard_tests)
示例#32
0
def load_tests(standard_tests, module, loader):
    submod_tests = loader.loadTestsFromModuleNames([
        'bzrlib.tests.per_interrepository.test_fetch',
        'bzrlib.tests.per_interrepository.test_interrepository',
    ])
    scenarios = make_scenarios(
        default_transport,
        # None here will cause a readonly decorator to be created
        # by the TestCaseWithTransport.get_readonly_transport method.
        None,
        default_test_list())
    return multiply_tests(submod_tests, scenarios, standard_tests)
示例#33
0
def load_tests(standard_tests, module, loader):
    colo_supported_formats = []
    colo_unsupported_formats = []
    # This will always add scenarios using the smart server.
    from bzrlib.remote import RemoteBzrDirFormat
    for format in ControlDirFormat.known_formats():
        if isinstance(format, RemoteBzrDirFormat):
            continue
        if format.colocated_branches:
            colo_supported_formats.append(format)
        else:
            colo_unsupported_formats.append(format)
    supported_scenarios = make_scenarios(default_transport, None, None,
                                         colo_supported_formats)
    unsupported_scenarios = make_scenarios(default_transport, None, None,
                                           colo_unsupported_formats)
    # test the remote server behaviour when backed with a MemoryTransport
    # Once for the current version
    unsupported_scenarios.extend(
        make_scenarios(memory.MemoryServer,
                       test_server.SmartTCPServer_for_testing,
                       test_server.ReadonlySmartTCPServer_for_testing,
                       [(RemoteBzrDirFormat())],
                       name_suffix='-default'))
    # And once with < 1.6 - the 'v2' protocol.
    unsupported_scenarios.extend(
        make_scenarios(memory.MemoryServer,
                       test_server.SmartTCPServer_for_testing_v2_only,
                       test_server.ReadonlySmartTCPServer_for_testing_v2_only,
                       [(RemoteBzrDirFormat())],
                       name_suffix='-v2'))

    result = loader.suiteClass()
    supported_tests = loader.loadTestsFromModuleNames(
        ['bzrlib.tests.per_controldir_colo.test_supported'])
    unsupported_tests = loader.loadTestsFromModuleNames(
        ['bzrlib.tests.per_controldir_colo.test_unsupported'])
    multiply_tests(supported_tests, supported_scenarios, result)
    multiply_tests(unsupported_tests, unsupported_scenarios, result)
    return result
示例#34
0
def load_tests(standard_tests, module, loader):
    colo_supported_formats = []
    colo_unsupported_formats = []
    # This will always add scenarios using the smart server.
    from bzrlib.remote import RemoteBzrDirFormat
    for format in ControlDirFormat.known_formats():
        if isinstance(format, RemoteBzrDirFormat):
            continue
        if format.colocated_branches:
            colo_supported_formats.append(format)
        else:
            colo_unsupported_formats.append(format)
    supported_scenarios = make_scenarios(default_transport, None, None,
        colo_supported_formats)
    unsupported_scenarios = make_scenarios(default_transport, None, None,
        colo_unsupported_formats)
    # test the remote server behaviour when backed with a MemoryTransport
    # Once for the current version
    unsupported_scenarios.extend(make_scenarios(
        memory.MemoryServer,
        test_server.SmartTCPServer_for_testing,
        test_server.ReadonlySmartTCPServer_for_testing,
        [(RemoteBzrDirFormat())],
        name_suffix='-default'))
    # And once with < 1.6 - the 'v2' protocol.
    unsupported_scenarios.extend(make_scenarios(
        memory.MemoryServer,
        test_server.SmartTCPServer_for_testing_v2_only,
        test_server.ReadonlySmartTCPServer_for_testing_v2_only,
        [(RemoteBzrDirFormat())],
        name_suffix='-v2'))

    result = loader.suiteClass()
    supported_tests = loader.loadTestsFromModuleNames([
        'bzrlib.tests.per_controldir_colo.test_supported'])
    unsupported_tests = loader.loadTestsFromModuleNames([
        'bzrlib.tests.per_controldir_colo.test_unsupported'])
    multiply_tests(supported_tests, supported_scenarios, result)
    multiply_tests(unsupported_tests, unsupported_scenarios, result)
    return result
示例#35
0
def test_suite():
    tests = unittest.TestLoader().loadTestsFromName(__name__)
    scenarios = [
        (
            'ftp',
            {
                'server_factory': FTPServer,
                # XXX: In an ideal world, this would be in the UnitTests
                # layer. Let's get one step closer to that ideal world.
                'layer': ZopelessDatabaseLayer
            }),
        ('sftp', {
            'server_factory': SFTPServer,
            'layer': ZopelessAppServerLayer
        }),
    ]
    suite = unittest.TestSuite()
    multiply_tests(tests, scenarios, suite)
    # SFTP doesn't have the concept of the server changing directories, since
    # clients will only send absolute paths, so drop that test.
    return exclude_tests_by_condition(
        suite, condition_id_re(r'test_change_directory.*\(sftp\)$'))
示例#36
0
def load_tests(standard_tests, module, loader):
    submod_tests = loader.loadTestsFromModuleNames([
        'bzrlib.tests.per_interrepository.test_fetch',
        'bzrlib.tests.per_interrepository.test_interrepository',
        ])
    scenarios = make_scenarios(
        default_transport,
        # None here will cause a readonly decorator to be created
        # by the TestCaseWithTransport.get_readonly_transport method.
        None,
        default_test_list()
        )
    return multiply_tests(submod_tests, scenarios, standard_tests)
示例#37
0
def make_smoke_tests(base_suite):
    from bzrlib.tests.per_repository import (
        all_repository_format_scenarios,
        )
    excluded_scenarios = [
        # RepositoryFormat4 is not initializable (bzrlib raises TestSkipped
        # when you try).
        'RepositoryFormat4',
        # Fetching weave formats from the smart server is known to be broken.
        # See bug 173807 and bzrlib.tests.test_repository.
        'RepositoryFormat5',
        'RepositoryFormat6',
        'RepositoryFormat7',
        'GitRepositoryFormat',
        'SvnRepositoryFormat',
        ]
    scenarios = all_repository_format_scenarios()
    scenarios = [
        scenario for scenario in scenarios
        if scenario[0] not in excluded_scenarios
        and not scenario[0].startswith('RemoteRepositoryFormat')]
    new_suite = unittest.TestSuite()
    multiply_tests(base_suite, scenarios, new_suite)
    return new_suite
示例#38
0
def load_tests(standard_tests, module, loader):
    module_list = [
        'bzrlib.tests.per_repository_reference.test_add_inventory',
        'bzrlib.tests.per_repository_reference.test_add_revision',
        'bzrlib.tests.per_repository_reference.test_add_signature_text',
        'bzrlib.tests.per_repository_reference.test_all_revision_ids',
        'bzrlib.tests.per_repository_reference.test_break_lock',
        'bzrlib.tests.per_repository_reference.test_check',
        'bzrlib.tests.per_repository_reference.test_commit_with_stacking',
        'bzrlib.tests.per_repository_reference.test_default_stacking',
        'bzrlib.tests.per_repository_reference.test_fetch',
        'bzrlib.tests.per_repository_reference.test_get_record_stream',
        'bzrlib.tests.per_repository_reference.test_get_rev_id_for_revno',
        'bzrlib.tests.per_repository_reference.test_graph',
        'bzrlib.tests.per_repository_reference.test_initialize',
        'bzrlib.tests.per_repository_reference.test__make_parents_provider',
        'bzrlib.tests.per_repository_reference.test_unlock',
        ]
    # Parameterize per_repository_reference test modules by format.
    standard_tests.addTests(loader.loadTestsFromModuleNames(module_list))
    return multiply_tests(standard_tests, external_reference_test_scenarios(),
        loader.suiteClass())
 def test_multiply_tests(self):
     loader = TestLoader()
     suite = loader.suiteClass()
     multiply_tests(self, vary_by_color(), suite)
     self.assertEqual(['blue', 'green', 'red'],
                      get_generated_test_attributes(suite, 'color'))
示例#40
0
def load_tests(standard_tests, module, loader):
    default_tree_format = WorkingTreeFormat3()
    submod_tests = loader.loadTestsFromModuleNames([
        'bzrlib.tests.per_intertree.test_compare',
        'bzrlib.tests.per_intertree.test_file_content_matches',
        ])
    test_intertree_permutations = [
        # test InterTree with two default-format working trees.
        (InterTree.__name__, InterTree,
         default_tree_format, default_tree_format,
         return_provided_trees)]
    for optimiser in InterTree._optimisers:
        if optimiser is revisiontree.InterCHKRevisionTree:
            # XXX: we shouldn't use an Intertree object to detect inventories
            # -- vila 20090311
            chk_tree_format = WorkingTreeFormat4()
            chk_tree_format._get_matchingbzrdir = \
                lambda:bzrlib.controldir.format_registry.make_bzrdir('2a')
            test_intertree_permutations.append(
                (InterTree.__name__ + "(CHKInventory)",
                 InterTree,
                 chk_tree_format,
                 chk_tree_format,
                 mutable_trees_to_revision_trees))
        elif optimiser is bzrlib.workingtree_4.InterDirStateTree:
            # Its a little ugly to be conditional here, but less so than having
            # the optimiser listed twice.
            # Add once, compiled version
            test_intertree_permutations.append(
                (optimiser.__name__ + "(C)",
                 optimiser,
                 optimiser._matching_from_tree_format,
                 optimiser._matching_to_tree_format,
                 optimiser.make_source_parent_tree_compiled_dirstate))
            # python version
            test_intertree_permutations.append(
                (optimiser.__name__ + "(PY)",
                 optimiser,
                 optimiser._matching_from_tree_format,
                 optimiser._matching_to_tree_format,
                 optimiser.make_source_parent_tree_python_dirstate))
        elif (optimiser._matching_from_tree_format is not None and 
              optimiser._matching_to_tree_format is not None):
            test_intertree_permutations.append(
                (optimiser.__name__,
                 optimiser,
                 optimiser._matching_from_tree_format,
                 optimiser._matching_to_tree_format,
                 optimiser._test_mutable_trees_to_test_trees))
    # PreviewTree does not have an InterTree optimiser class.
    test_intertree_permutations.append(
        (InterTree.__name__ + "(PreviewTree)",
         InterTree,
         default_tree_format,
         default_tree_format,
         mutable_trees_to_preview_trees))
    scenarios = make_scenarios(
        default_transport,
        # None here will cause a readonly decorator to be created
        # by the TestCaseWithTransport.get_readonly_transport method.
        None,
        test_intertree_permutations)
    # add the tests for the sub modules to the standard tests.
    return multiply_tests(submod_tests, scenarios, standard_tests)
示例#41
0
def load_tests(standard_tests, module, loader):
    """Parameterize the test for tempfile creation with different encodings."""
    to_adapt, result = split_suite_by_re(standard_tests, "test__create_temp_file_with_commit_template_in_unicode_dir")
    return multiply_tests(to_adapt, encoding_scenarios, result)
def load_tests(standard_tests, module, loader):
    """Parameterize the test for tempfile creation with different encodings."""
    to_adapt, result = split_suite_by_re(
        standard_tests,
        "test__create_temp_file_with_commit_template_in_unicode_dir")
    return multiply_tests(to_adapt, encoding_scenarios, result)