~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-06 15:38:24 UTC
  • mto: This revision was merged to the branch mainline in revision 5390.
  • Revision ID: john@arbash-meinel.com-20100806153824-inx9xjyuzneci1qw
A __sizeof__ check that ensure we are getting what we are looking for.

It also checks that it grows appropriately for how many new entries are added.

Show diffs side-by-side

added added

removed removed

Lines of Context:
291
291
            self.assertEqual(lst.index(val), offsets[val])
292
292
        for idx, key in enumerate(leaf.all_keys()):
293
293
            self.assertEqual(str(idx), leaf[key][0].split()[0])
 
294
 
 
295
    def test__sizeof__(self):
 
296
        # We can't use the exact numbers because of platform variations, etc.
 
297
        # But what we really care about is that it does get bigger with more
 
298
        # content.
 
299
        leaf0 = self.module._parse_into_chk('type=leaf\n', 1, 0)
 
300
        leaf1 = self.module._parse_into_chk(_one_key_content, 1, 0)
 
301
        leafN = self.module._parse_into_chk(_multi_key_content, 1, 0)
 
302
        sizeof_1 = leaf1.__sizeof__() - leaf0.__sizeof__()
 
303
        self.assertTrue(sizeof_1 > 0)
 
304
        sizeof_N = leafN.__sizeof__() - leaf0.__sizeof__()
 
305
        self.assertEqual(sizeof_1 * len(leafN), sizeof_N)