Rev 2494: Apply all of the tests for DirState.bisect_dirblock to the compiled function. in http://bzr.arbash-meinel.com/branches/bzr/0.17-dev/dirstate_pyrex

John Arbash Meinel john at arbash-meinel.com
Fri May 4 18:46:30 BST 2007


At http://bzr.arbash-meinel.com/branches/bzr/0.17-dev/dirstate_pyrex

------------------------------------------------------------
revno: 2494
revision-id: john at arbash-meinel.com-20070504174616-4kdi7zi32h7ev4f9
parent: john at arbash-meinel.com-20070504173600-5reyrpo013nk17sr
committer: John Arbash Meinel <john at arbash-meinel.com>
branch nick: dirstate_pyrex
timestamp: Fri 2007-05-04 12:46:16 -0500
message:
  Apply all of the tests for DirState.bisect_dirblock to the compiled function.
modified:
  bzrlib/tests/compiled/test_dirstate_helpers.py test_dirstate_helper-20070504035751-jsbn00xodv0y1eve-2
  bzrlib/tests/test_dirstate.py  test_dirstate.py-20060728012006-d6mvoihjb3je9peu-2
-------------- next part --------------
=== modified file 'bzrlib/tests/compiled/test_dirstate_helpers.py'
--- a/bzrlib/tests/compiled/test_dirstate_helpers.py	2007-05-04 16:35:23 +0000
+++ b/bzrlib/tests/compiled/test_dirstate_helpers.py	2007-05-04 17:46:16 +0000
@@ -16,7 +16,6 @@
 
 """Tests for the compiled dirstate helpers."""
 
-
 from bzrlib import (
     tests,
     )
@@ -26,6 +25,7 @@
     have_dirstate_helpers = False
 else:
     have_dirstate_helpers = True
+from bzrlib.tests import test_dirstate
 
 
 class _CompiledDirstateHelpersFeature(tests.Feature):
@@ -134,3 +134,23 @@
         self.assertStrCmp(-1, 'ab/cd/ef', 'ab/cd-ef')
         self.assertStrCmp(-1, 'ab/cd', 'ab/cd-')
         self.assertStrCmp(-1, 'ab/cd', 'ab-cd')
+
+
+class TestCompiledBisectDirblock(test_dirstate.TestBisectDirblock):
+    """Test that bisect_dirblock() returns the expected values.
+
+    bisect_dirblock is intended to work like bisect.bisect_left() except it
+    knows it is working on dirblocks and that dirblocks are sorted by ('path',
+    'to', 'foo') chunks rather than by raw 'path/to/foo'.
+
+    This runs all the normal tests that TestBisectDirblock did, but uses the
+    compiled version.
+    """
+
+    _test_needs_features = [CompiledDirstateHelpersFeature]
+
+    if have_dirstate_helpers:
+        bisect_dirblock_func = dirstate_helpers.bisect_dirblock
+    else:
+        bisect_dirblock_func = None
+

=== modified file 'bzrlib/tests/test_dirstate.py'
--- a/bzrlib/tests/test_dirstate.py	2007-04-19 18:27:56 +0000
+++ b/bzrlib/tests/test_dirstate.py	2007-05-04 17:46:16 +0000
@@ -1977,6 +1977,8 @@
     'to', 'foo') chunks rather than by raw 'path/to/foo'.
     """
 
+    bisect_dirblock_func = dirstate.bisect_dirblock
+
     def assertBisect(self, dirblocks, split_dirblocks, path, *args, **kwargs):
         """Assert that bisect_split works like bisect_left on the split paths.
 
@@ -1986,8 +1988,8 @@
 
         All other arguments will be passed along.
         """
-        bisect_split_idx = dirstate.bisect_dirblock(dirblocks, path,
-                                                 *args, **kwargs)
+        bisect_split_idx = self.bisect_dirblock_func(dirblocks, path,
+                                                     *args, **kwargs)
         split_dirblock = (path.split('/'), [])
         bisect_left_idx = bisect.bisect_left(split_dirblocks, split_dirblock,
                                              *args)



More information about the bazaar-commits mailing list