def non_caching_scenarios(): scenarios = [ ('python-nocache', {'module': _known_graph_py, 'do_cache': False}), ] if compiled_known_graph_feature.available(): scenarios.append( ('C-nocache', {'module': compiled_known_graph_feature.module, 'do_cache': False})) return scenarios load_tests = load_tests_apply_scenarios compiled_known_graph_feature = features.ModuleAvailableFeature( 'bzrlib._known_graph_pyx') # a # |\ # b | # | | # c | # \| # d alt_merge = {'a': [], 'b': ['a'], 'c': ['b'], 'd': ['a', 'c']} class TestCaseWithKnownGraph(tests.TestCase): scenarios = caching_scenarios()
def test_available_module(self): feature = features.ModuleAvailableFeature('bzrlib.tests') self.assertEqual('bzrlib.tests', feature.module_name) self.assertEqual('bzrlib.tests', str(feature)) self.assertTrue(feature.available()) self.assertIs(tests, feature.module)
def test_unavailable_module(self): feature = features.ModuleAvailableFeature( 'bzrlib.no_such_module_exists') self.assertEqual('bzrlib.no_such_module_exists', str(feature)) self.assertFalse(feature.available()) self.assertIs(None, feature.module)
raise ValueError('I can only be hashed once.') class _BadCompare(_Hashable): def __eq__(self, other): raise RuntimeError('I refuse to play nice') class _NoImplementCompare(_Hashable): def __eq__(self, other): return NotImplemented # Even though this is an extension, we don't permute the tests for a python # version. As the plain python version is just a dict or set compiled_simpleset_feature = features.ModuleAvailableFeature( 'bzrlib._simple_set_pyx') class TestSimpleSet(tests.TestCase): _test_needs_features = [compiled_simpleset_feature] module = _simple_set_pyx def assertIn(self, obj, container): self.assertTrue(obj in container, '%s not found in %s' % (obj, container)) def assertNotIn(self, obj, container): self.assertTrue(obj not in container, 'We found %s in %s' % (obj, container))
from bzrlib import tests from bzrlib.tests import ( features, ) def load_tests(standard_tests, module, loader): suite, _ = tests.permute_tests_for_extension( standard_tests, loader, 'bzrlib._chunks_to_lines_py', 'bzrlib._chunks_to_lines_pyx') return suite # test_osutils depends on this feature being around. We can't just use the one # generated by load_tests, because if we only load osutils but not this module, # then that code never gets run compiled_chunkstolines_feature = features.ModuleAvailableFeature( 'bzrlib._chunks_to_lines_pyx') class TestChunksToLines(tests.TestCase): module = None # Filled in by test parameterization def assertChunksToLines(self, lines, chunks, alreadly_lines=False): result = self.module.chunks_to_lines(chunks) self.assertEqual(lines, result) if alreadly_lines: self.assertIs(chunks, result) def test_fulltext_chunk_to_lines(self): self.assertChunksToLines(['foo\n', 'bar\r\n', 'ba\rz\n'], ['foo\nbar\r\nba\rz\n'])
# # You should have received a copy of the GNU General Public License # along with this program; if not, write to the Free Software # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA """Tests for the win32 walkdir extension.""" import errno from bzrlib import ( osutils, tests, ) from bzrlib.tests import ( features, ) win32_readdir_feature = features.ModuleAvailableFeature( 'bzrlib._walkdirs_win32') class TestWin32Finder(tests.TestCaseInTempDir): _test_needs_features = [win32_readdir_feature] def setUp(self): super(TestWin32Finder, self).setUp() from bzrlib._walkdirs_win32 import ( Win32ReadDir, ) self.reader = Win32ReadDir() def _remove_stat_from_dirblock(self, dirblock): return [info[:3] + info[4:] for info in dirblock]
}), ('PC', { 'make_delta': _groupcompress_py.make_delta, 'apply_delta': gc_module.apply_delta }), ('CP', { 'make_delta': gc_module.make_delta, 'apply_delta': _groupcompress_py.apply_delta }), ]) return scenarios load_tests = load_tests_apply_scenarios compiled_groupcompress_feature = features.ModuleAvailableFeature( 'bzrlib._groupcompress_pyx') _text1 = """\ This is a bit of source text which is meant to be matched against other text """ _text2 = """\ This is a bit of source text which is meant to differ from against other text """
tests, win32utils, ) from bzrlib.tests import ( TestCase, TestCaseInTempDir, TestSkipped, ) from bzrlib.tests.features import backslashdir_feature from bzrlib.win32utils import glob_expand, get_app_path from bzrlib.tests import ( features, ) Win32RegistryFeature = features.ModuleAvailableFeature('_winreg') CtypesFeature = features.ModuleAvailableFeature('ctypes') Win32comShellFeature = features.ModuleAvailableFeature('win32com.shell') Win32ApiFeature = features.ModuleAvailableFeature('win32api') # Tests # ----- class TestWin32UtilsGlobExpand(TestCaseInTempDir): _test_needs_features = [] def test_empty_tree(self): self.build_tree([]) self._run_testset([