~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/tests/test_btree_index.py

  • Committer: Canonical.com Patch Queue Manager
  • Date: 2010-01-26 10:49:57 UTC
  • mfrom: (4987.1.1 integration)
  • Revision ID: pqm@pqm.ubuntu.com-20100126104957-dmtqnc0pckuruyla
(vila,
        jam) Implement TestCase.overrideAttr to simplify tests setUp/cleanup

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