~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/tests/__init__.py

  • Committer: John Arbash Meinel
  • Date: 2009-12-22 16:28:47 UTC
  • mto: This revision was merged to the branch mainline in revision 4922.
  • Revision ID: john@arbash-meinel.com-20091222162847-tvnsc69to4l4uf5r
Implement a permute_for_extension helper.

Use it for all of the 'simple' extension permutations.
It basically permutes all tests in the current module, by setting TestCase.module.
Which works well for most of our extension tests. Some had more advanced
handling of permutations (extra permutations, custom vars, etc.)

Show diffs side-by-side

added added

removed removed

Lines of Context:
4139
4139
    return new_test
4140
4140
 
4141
4141
 
 
4142
def permute_tests_for_extension(standard_tests, loader, py_module_name,
 
4143
                                ext_module_name):
 
4144
    py_module = __import__(py_module_name, {}, {}, ['NO_SUCH_ATTRIB'])
 
4145
    scenarios = [
 
4146
        ('python', {'module': py_module}),
 
4147
    ]
 
4148
    suite = loader.suiteClass()
 
4149
    feature = ModuleAvailableFeature(ext_module_name)
 
4150
    if feature.available():
 
4151
        scenarios.append(('C', {'module': feature.module}))
 
4152
    else:
 
4153
        # the compiled module isn't available, so we add a failing test
 
4154
        class FailWithoutFeature(TestCase):
 
4155
            def test_fail(self):
 
4156
                self.requireFeature(feature)
 
4157
        suite.addTest(loader.loadTestsFromTestCase(FailWithoutFeature))
 
4158
    result = multiply_tests(standard_tests, scenarios, suite)
 
4159
    return result, feature
 
4160
 
 
4161
 
4142
4162
def _rmtree_temp_dir(dirname, test_id=None):
4143
4163
    # If LANG=C we probably have created some bogus paths
4144
4164
    # which rmtree(unicode) will fail to delete