Beispiel #1
0
def load_tests(standard_tests, module, loader):
    """Multiply tests for tranport implementations."""
    result = loader.suiteClass()
    adapter = TransportTestProviderAdapter()
    for test in tests.iter_suite_tests(standard_tests):
        result.addTests(adapter.adapt(test))
    return result
Beispiel #2
0
def adapt_suite(adapter, base_suite):
    from bzrlib.tests import iter_suite_tests

    suite = unittest.TestSuite()
    for test in iter_suite_tests(base_suite):
        suite.addTests(adapter.adapt(test))
    return suite
Beispiel #3
0
def load_tests(standard_tests, module, loader):
    """Multiply tests for tranport implementations."""
    result = loader.suiteClass()
    adapter = TransportTestProviderAdapter()
    for test in tests.iter_suite_tests(standard_tests):
        result.addTests(adapter.adapt(test))
    return result
Beispiel #4
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")
    for test in iter_suite_tests(to_adapt):
        result.addTests(EncodingTestAdapter().adapt(test))
    return result
Beispiel #5
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")
    for test in iter_suite_tests(to_adapt):
        result.addTests(EncodingTestAdapter().adapt(test))
    return result
Beispiel #6
0
def load_tests(standard_tests, module, loader):
    """Multiply tests version and protocol consistency."""
    # FindRepository tests.
    bzrdir_mod = bzrlib.smart.bzrdir
    applier = TestScenarioApplier()
    applier.scenarios = [
        ("find_repository", {
            "_request_class":bzrdir_mod.SmartServerRequestFindRepositoryV1}),
        ("find_repositoryV2", {
            "_request_class":bzrdir_mod.SmartServerRequestFindRepositoryV2}),
        ]
    to_adapt, result = split_suite_by_re(standard_tests,
        "TestSmartServerRequestFindRepository")
    v2_only, v1_and_2 = split_suite_by_re(to_adapt,
        "_v2")
    for test in iter_suite_tests(v1_and_2):
        result.addTests(applier.adapt(test))
    del applier.scenarios[0]
    for test in iter_suite_tests(v2_only):
        result.addTests(applier.adapt(test))
    return result
Beispiel #7
0
    def test_dir_construction_and_trivial_running(self):
        test_filename = os.path.join(self.tempdir, 'xx-foo.txt')
        test_file = open(test_filename, 'wt')
        test_file.close()
        test_filename = os.path.join(self.tempdir, 'xx-bar.txt')
        test_file = open(test_filename, 'wt')
        test_file.close()
        # The test directory is looked up relative to the calling
        # module's path.
        suite = PageTestSuite(os.path.basename(self.tempdir))
        self.assertTrue(isinstance(suite, unittest.TestSuite))
        tests = list(iter_suite_tests(suite))

        # Each unnumbered file appears as an independent test.
        ids = set(map(os.path.basename, map(methodcaller('id'), tests)))
        self.assertEqual(set(['xx-bar.txt', 'xx-foo.txt']), ids)
Beispiel #8
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)
Beispiel #9
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)
Beispiel #10
0
    def test_dir_construction_and_trivial_running(self):
        test_filename = os.path.join(self.tempdir, 'xx-foo.txt')
        test_file = open(test_filename, 'wt')
        test_file.close()
        test_filename = os.path.join(self.tempdir, 'xx-bar.txt')
        test_file = open(test_filename, 'wt')
        test_file.close()
        # The test directory is looked up relative to the calling
        # module's path.
        suite = PageTestSuite(os.path.basename(self.tempdir))
        self.failUnless(isinstance(suite, unittest.TestSuite))
        tests = list(iter_suite_tests(suite))

        # Each unnumbered file appears as an independent test.
        ids = set(map(os.path.basename, map(methodcaller('id'), tests)))
        self.assertEqual(set(['xx-bar.txt', 'xx-foo.txt']), ids)
Beispiel #11
0
def load_tests(basic_tests, module, loader):
    """This module creates its own test suite with DocFileSuite."""

    dir_ = os.path.dirname(__file__)
    if os.path.isdir(dir_):
        candidates = os.listdir(dir_)
    else:
        candidates = []
    scripts = [candidate for candidate in candidates
               if candidate.endswith('.txt')]
    # since this module doesn't define tests, we ignore basic_tests
    suite = doctest.DocFileSuite(*scripts)
    # DocFileCase reduces the test id to the base name of the tested file, we
    # want the module to appears there.
    for t in tests.iter_suite_tests(suite):
        def make_new_test_id():
            new_id = '%s.DocFileTest(%s)' % ( __name__, t)
            return lambda: new_id
        t.id = make_new_test_id()
    return suite
Beispiel #12
0
def load_tests(basic_tests, module, loader):
    """This module creates its own test suite with DocFileSuite."""

    dir_ = os.path.dirname(__file__)
    if os.path.isdir(dir_):
        candidates = os.listdir(dir_)
    else:
        candidates = []
    scripts = [candidate for candidate in candidates
               if candidate.endswith('.txt')]
    # since this module doesn't define tests, we ignore basic_tests
    suite = doctest.DocFileSuite(*scripts)
    # DocFileCase reduces the test id to the base name of the tested file, we
    # want the module to appears there.
    for t in tests.iter_suite_tests(suite):
        def make_new_test_id():
            new_id = '%s.DocFileTest(%s)' % ( __name__, t)
            return lambda: new_id
        t.id = make_new_test_id()
    return suite
def get_generated_test_attributes(suite, attr_name):
    """Return the `attr_name` attribute from all tests in the suite"""
    return sorted([getattr(t, attr_name) for t in iter_suite_tests(suite)])
Beispiel #14
0
 def test_multiply_tests_no_scenarios(self):
     """Tests with no scenarios attribute aren't multiplied"""
     suite = TestLoader().suiteClass()
     multiply_tests_by_their_scenarios(self,
         suite)
     self.assertLength(1, list(iter_suite_tests(suite)))
Beispiel #15
0
def get_generated_test_attributes(suite, attr_name):
    """Return the `attr_name` attribute from all tests in the suite"""
    return sorted([
        getattr(t, attr_name) for t in iter_suite_tests(suite)])
 def test_multiply_tests_no_scenarios(self):
     """Tests with no scenarios attribute aren't multiplied"""
     suite = TestLoader().suiteClass()
     multiply_tests_by_their_scenarios(self, suite)
     self.assertLength(1, list(iter_suite_tests(suite)))
Beispiel #17
0
def adapt_suite(adapter, base_suite):
    from bzrlib.tests import iter_suite_tests
    suite = unittest.TestSuite()
    for test in iter_suite_tests(base_suite):
        suite.addTests(adapter.adapt(test))
    return suite