~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/tests/test_btree_index.py

  • Committer: John Arbash Meinel
  • Date: 2009-12-22 17:14:45 UTC
  • mto: This revision was merged to the branch mainline in revision 4922.
  • Revision ID: john@arbash-meinel.com-20091222171445-fm7lcwhmkfdkc01q
Handle the fact that osutils requires the feature to be available.

Show diffs side-by-side

added added

removed removed

Lines of Context:
59
59
 
60
60
    def setUp(self):
61
61
        TestCaseWithTransport.setUp(self)
62
 
        self.overrideAttr(btree_index, '_RESERVED_HEADER_BYTES', 100)
 
62
        self._original_header = btree_index._RESERVED_HEADER_BYTES
 
63
        def restore():
 
64
            btree_index._RESERVED_HEADER_BYTES = self._original_header
 
65
        self.addCleanup(restore)
 
66
        btree_index._RESERVED_HEADER_BYTES = 100
63
67
 
64
68
    def make_nodes(self, count, key_elements, reference_lists):
65
69
        """Generate count*key_elements sample nodes."""
99
103
 
100
104
    def shrink_page_size(self):
101
105
        """Shrink the default page size so that less fits in a page."""
102
 
        self.overrideAttr(btree_index, '_PAGE_SIZE')
 
106
        old_page_size = btree_index._PAGE_SIZE
 
107
        def cleanup():
 
108
            btree_index._PAGE_SIZE = old_page_size
 
109
        self.addCleanup(cleanup)
103
110
        btree_index._PAGE_SIZE = 2048
104
111
 
105
112
 
1150
1157
 
1151
1158
class TestBTreeNodes(BTreeTestCase):
1152
1159
 
 
1160
    def restore_parser(self):
 
1161
        btree_index._btree_serializer = self.saved_parser
 
1162
 
1153
1163
    def setUp(self):
1154
1164
        BTreeTestCase.setUp(self)
1155
 
        self.overrideAttr(btree_index, '_btree_serializer', self.parse_btree)
 
1165
        self.saved_parser = btree_index._btree_serializer
 
1166
        self.addCleanup(self.restore_parser)
 
1167
        btree_index._btree_serializer = self.parse_btree
1156
1168
 
1157
1169
    def test_LeafNode_1_0(self):
1158
1170
        node_bytes = ("type=leaf\n"