Rev 4766: Clean up the chk test suite a little bit. in http://bazaar.launchpad.net/~jameinel/bzr/2.1-static-tuple-chk-map
John Arbash Meinel
john at arbash-meinel.com
Thu Oct 8 17:04:05 BST 2009
At http://bazaar.launchpad.net/~jameinel/bzr/2.1-static-tuple-chk-map
------------------------------------------------------------
revno: 4766
revision-id: john at arbash-meinel.com-20091008160345-wnfh9gewhdvi8tbc
parent: john at arbash-meinel.com-20091008160153-krcoicv53v517v7f
committer: John Arbash Meinel <john at arbash-meinel.com>
branch nick: 2.1-static-tuple-chk-map
timestamp: Thu 2009-10-08 11:03:45 -0500
message:
Clean up the chk test suite a little bit.
-------------- next part --------------
=== modified file 'bzrlib/tests/test_chk_map.py'
--- a/bzrlib/tests/test_chk_map.py 2009-10-08 16:01:53 +0000
+++ b/bzrlib/tests/test_chk_map.py 2009-10-08 16:03:45 +0000
@@ -32,6 +32,7 @@
Node,
)
+key_types = (tuple, chk_map._key_type)
class TestNode(tests.TestCase):
@@ -831,13 +832,13 @@
# 'ab' and 'ac' nodes
chkmap.map(('aad',), 'v')
self.assertIsInstance(chkmap._root_node._items['aa'], InternalNode)
- self.assertIsInstance(chkmap._root_node._items['ab'], (tuple, chk_map._key_type))
- self.assertIsInstance(chkmap._root_node._items['ac'], (tuple, chk_map._key_type))
+ self.assertIsInstance(chkmap._root_node._items['ab'], key_types)
+ self.assertIsInstance(chkmap._root_node._items['ac'], key_types)
# Unmapping 'acd' can notice that 'aa' is an InternalNode and not have
# to map in 'ab'
chkmap.unmap(('acd',))
self.assertIsInstance(chkmap._root_node._items['aa'], InternalNode)
- self.assertIsInstance(chkmap._root_node._items['ab'], (tuple, chk_map._key_type))
+ self.assertIsInstance(chkmap._root_node._items['ab'], key_types)
def test_unmap_without_fitting_doesnt_page_in(self):
store = self.get_chk_bytes()
@@ -860,9 +861,8 @@
chkmap.map(('aaf',), 'v')
# At this point, the previous nodes should not be paged in, but the
# newly added nodes would be
- self.assertIsInstance(chkmap._root_node._items['aaa'], (tuple,
- chk_map._key_type))
- self.assertIsInstance(chkmap._root_node._items['aab'], (tuple, chk_map._key_type))
+ self.assertIsInstance(chkmap._root_node._items['aaa'], key_types)
+ self.assertIsInstance(chkmap._root_node._items['aab'], key_types)
self.assertIsInstance(chkmap._root_node._items['aac'], LeafNode)
self.assertIsInstance(chkmap._root_node._items['aad'], LeafNode)
self.assertIsInstance(chkmap._root_node._items['aae'], LeafNode)
@@ -870,8 +870,8 @@
# Now unmapping one of the new nodes will use only the already-paged-in
# nodes to determine that we don't need to do more.
chkmap.unmap(('aaf',))
- self.assertIsInstance(chkmap._root_node._items['aaa'], (tuple, chk_map._key_type))
- self.assertIsInstance(chkmap._root_node._items['aab'], (tuple, chk_map._key_type))
+ self.assertIsInstance(chkmap._root_node._items['aaa'], key_types)
+ self.assertIsInstance(chkmap._root_node._items['aab'], key_types)
self.assertIsInstance(chkmap._root_node._items['aac'], LeafNode)
self.assertIsInstance(chkmap._root_node._items['aad'], LeafNode)
self.assertIsInstance(chkmap._root_node._items['aae'], LeafNode)
@@ -898,12 +898,9 @@
chkmap.map(('aad',), 'v')
# At this point, the previous nodes should not be paged in, but the
# newly added node would be
- self.assertIsInstance(chkmap._root_node._items['aaa'], (tuple,
- chk_map._key_type))
- self.assertIsInstance(chkmap._root_node._items['aab'], (tuple,
- chk_map._key_type))
- self.assertIsInstance(chkmap._root_node._items['aac'], (tuple,
- chk_map._key_type))
+ self.assertIsInstance(chkmap._root_node._items['aaa'], key_types)
+ self.assertIsInstance(chkmap._root_node._items['aab'], key_types)
+ self.assertIsInstance(chkmap._root_node._items['aac'], key_types)
self.assertIsInstance(chkmap._root_node._items['aad'], LeafNode)
# Unmapping the new node will check the existing nodes to see if they
# would fit.
@@ -941,12 +938,9 @@
chkmap.map(('aad',), 'v')
# At this point, the previous nodes should not be paged in, but the
# newly added node would be
- self.assertIsInstance(chkmap._root_node._items['aaa'], (tuple,
- chk_map._key_type))
- self.assertIsInstance(chkmap._root_node._items['aab'], (tuple,
- chk_map._key_type))
- self.assertIsInstance(chkmap._root_node._items['aac'], (tuple,
- chk_map._key_type))
+ self.assertIsInstance(chkmap._root_node._items['aaa'], key_types)
+ self.assertIsInstance(chkmap._root_node._items['aab'], key_types)
+ self.assertIsInstance(chkmap._root_node._items['aac'], key_types)
self.assertIsInstance(chkmap._root_node._items['aad'], LeafNode)
# Now clear the page cache, and only include 2 of the children in the
# cache
@@ -961,8 +955,7 @@
# Unmapping the new node will check the nodes from the page cache
# first, and not have to read in 'aaa'
chkmap.unmap(('aad',))
- self.assertIsInstance(chkmap._root_node._items['aaa'], (tuple,
- chk_map._key_type))
+ self.assertIsInstance(chkmap._root_node._items['aaa'], key_types)
self.assertIsInstance(chkmap._root_node._items['aab'], LeafNode)
self.assertIsInstance(chkmap._root_node._items['aac'], LeafNode)
@@ -982,12 +975,9 @@
chkmap.map(('aaf',), 'val')
# At this point, the previous nodes should not be paged in, but the
# newly added node would be
- self.assertIsInstance(chkmap._root_node._items['aaa'], (tuple,
- chk_map._key_type))
- self.assertIsInstance(chkmap._root_node._items['aab'], (tuple,
- chk_map._key_type))
- self.assertIsInstance(chkmap._root_node._items['aac'], (tuple,
- chk_map._key_type))
+ self.assertIsInstance(chkmap._root_node._items['aaa'], key_types)
+ self.assertIsInstance(chkmap._root_node._items['aab'], key_types)
+ self.assertIsInstance(chkmap._root_node._items['aac'], key_types)
self.assertIsInstance(chkmap._root_node._items['aad'], LeafNode)
self.assertIsInstance(chkmap._root_node._items['aae'], LeafNode)
self.assertIsInstance(chkmap._root_node._items['aaf'], LeafNode)
@@ -995,12 +985,9 @@
# Unmapping a new node will see the other nodes that are already in
# memory, and not need to page in anything else
chkmap.unmap(('aad',))
- self.assertIsInstance(chkmap._root_node._items['aaa'], (tuple,
- chk_map._key_type))
- self.assertIsInstance(chkmap._root_node._items['aab'], (tuple,
- chk_map._key_type))
- self.assertIsInstance(chkmap._root_node._items['aac'], (tuple,
- chk_map._key_type))
+ self.assertIsInstance(chkmap._root_node._items['aaa'], key_types)
+ self.assertIsInstance(chkmap._root_node._items['aab'], key_types)
+ self.assertIsInstance(chkmap._root_node._items['aac'], key_types)
self.assertIsInstance(chkmap._root_node._items['aae'], LeafNode)
self.assertIsInstance(chkmap._root_node._items['aaf'], LeafNode)
@@ -1045,8 +1032,8 @@
{('a',): 'content here', ('b',): 'more content'},
chk_bytes=basis._store, maximum_size=10)
list(target.iter_changes(basis))
- self.assertIsInstance(target._root_node, (tuple, chk_map._key_type))
- self.assertIsInstance(basis._root_node, (tuple, chk_map._key_type))
+ self.assertIsInstance(target._root_node, key_types)
+ self.assertIsInstance(basis._root_node, key_types)
def test_iter_changes_ab_ab_changed_values_shown(self):
basis = self._get_map({('a',): 'content here', ('b',): 'more content'},
@@ -1946,7 +1933,7 @@
# Ensure test validity: nothing paged in below the root.
self.assertEqual(2,
len([value for value in node._items.values()
- if type(value) in (tuple, chk_map._key_type)]))
+ if type(value) in key_types]))
# now, mapping to k3 should add a k3 leaf
prefix, nodes = node.map(None, ('k3',), 'quux')
self.assertEqual("k", prefix)
@@ -1985,7 +1972,7 @@
# Ensure test validity: nothing paged in below the root.
self.assertEqual(2,
len([value for value in node._items.values()
- if type(value) in (tuple, chk_map._key_type)]))
+ if type(value) in key_types]))
# now, mapping to k23 causes k22 ('k2' in node) to split into k22 and
# k23, which for simplicity in the current implementation generates
# a new internal node between node, and k22/k23.
More information about the bazaar-commits
mailing list