~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/tests/test__btree_serializer.py

  • Committer: John Arbash Meinel
  • Date: 2010-08-23 17:51:17 UTC
  • mto: This revision was merged to the branch mainline in revision 5390.
  • Revision ID: john@arbash-meinel.com-20100823175117-hr3b7p8gkw4ap8bb
Change the _test names to _get and _py so that it doesn't provoke bad smells :)

Show diffs side-by-side

added added

removed removed

Lines of Context:
38
38
 
39
39
    def assertHexlify(self, as_binary):
40
40
        self.assertEqual(binascii.hexlify(as_binary),
41
 
                         self.module._test_hexlify(as_binary))
 
41
                         self.module._py_hexlify(as_binary))
42
42
 
43
43
    def assertUnhexlify(self, as_hex):
44
44
        ba_unhex = binascii.unhexlify(as_hex)
45
 
        mod_unhex = self.module._test_unhexlify(as_hex)
 
45
        mod_unhex = self.module._py_unhexlify(as_hex)
46
46
        if ba_unhex != mod_unhex:
47
47
            if mod_unhex is None:
48
48
                mod_hex = '<None>'
49
49
            else:
50
50
                mod_hex = binascii.hexlify(mod_unhex)
51
 
            self.fail('_test_unhexlify returned a different answer'
 
51
            self.fail('_py_unhexlify returned a different answer'
52
52
                      ' from binascii:\n    %s\n != %s'
53
53
                      % (binascii.hexlify(ba_unhex), mod_hex))
54
54
 
55
55
    def assertFailUnhexlify(self, as_hex):
56
56
        # Invalid hex content
57
 
        self.assertIs(None, self.module._test_unhexlify(as_hex))
 
57
        self.assertIs(None, self.module._py_unhexlify(as_hex))
58
58
 
59
59
    def test_to_hex(self):
60
60
        raw_bytes = ''.join(map(chr, range(256)))
86
86
            expected_bin = None
87
87
        else:
88
88
            expected_bin = binascii.unhexlify(expected)
89
 
        actual_sha1 = self.module._test_key_to_sha1(key)
 
89
        actual_sha1 = self.module._py_key_to_sha1(key)
90
90
        if expected_bin != actual_sha1:
91
91
            actual_hex_sha1 = None
92
92
            if actual_sha1 is not None:
121
121
 
122
122
    def assertSha1ToKey(self, hex_sha1):
123
123
        bin_sha1 = binascii.unhexlify(hex_sha1)
124
 
        key = self.module._test_sha1_to_key(bin_sha1)
 
124
        key = self.module._py_sha1_to_key(bin_sha1)
125
125
        self.assertEqual(('sha1:' + hex_sha1,), key)
126
126
 
127
127
    def test_simple(self):
229
229
        # The interesting byte for each key is
230
230
        # (defined as the 8-bits that come after the common prefix)
231
231
        lst = [1, 13, 28, 180, 190, 193, 210, 239]
232
 
        offsets = leaf._test_offsets
 
232
        offsets = leaf._get_offsets()
233
233
        self.assertEqual([bisect.bisect_left(lst, x) for x in range(0, 257)],
234
234
                         offsets)
235
235
        for idx, val in enumerate(lst):
241
241
        # there is no common prefix, though there are some common bits
242
242
        leaf = self.module._parse_into_chk(_multi_key_same_offset, 1, 0)
243
243
        self.assertEqual(24, leaf.common_shift)
244
 
        offsets = leaf._test_offsets
 
244
        offsets = leaf._get_offsets()
245
245
        # The interesting byte is just the first 8-bits of the key
246
246
        lst = [8, 200, 205, 205, 205, 205, 206, 206]
247
247
        self.assertEqual([bisect.bisect_left(lst, x) for x in range(0, 257)],
257
257
        leaf = self.module._parse_into_chk(_common_32_bits, 1, 0)
258
258
        self.assertEqual(0, leaf.common_shift)
259
259
        lst = [0x78] * 8
260
 
        offsets = leaf._test_offsets
 
260
        offsets = leaf._get_offsets()
261
261
        self.assertEqual([bisect.bisect_left(lst, x) for x in range(0, 257)],
262
262
                         offsets)
263
263
        for val in lst:
277
277
        bytes = ''.join(lines)
278
278
        leaf = self.module._parse_into_chk(bytes, 1, 0)
279
279
        self.assertEqual(24-7, leaf.common_shift)
280
 
        offsets = leaf._test_offsets
 
280
        offsets = leaf._get_offsets()
281
281
        # This is the interesting bits for each entry
282
282
        lst = [x // 2 for x in range(500)]
283
283
        expected_offsets = [x * 2 for x in range(128)] + [255]*129