[Checkins] SVN: BTrees/branches/pure_python/ Better test method names.
Tres Seaver
cvs-admin at zope.org
Sun Nov 11 20:51:52 UTC 2012
Log message for revision 128238:
Better test method names.
Changed:
_U BTrees/branches/pure_python/
U BTrees/branches/pure_python/BTrees/tests/test_check.py
-=-
Modified: BTrees/branches/pure_python/BTrees/tests/test_check.py
===================================================================
--- BTrees/branches/pure_python/BTrees/tests/test_check.py 2012-11-11 20:51:51 UTC (rev 128237)
+++ BTrees/branches/pure_python/BTrees/tests/test_check.py 2012-11-11 20:51:51 UTC (rev 128238)
@@ -11,13 +11,15 @@
# FOR A PARTICULAR PURPOSE.
#
##############################################################################
-"""Test the BTree check.check() function."""
-
import unittest
-class CheckTest(unittest.TestCase):
+class Test_check(unittest.TestCase):
+ def _callFUT(self, tree):
+ from BTrees.check import check
+ return check(tree)
+
def _makeOne(self):
from BTrees.OOBTree import OOBTree
tree = OOBTree()
@@ -25,21 +27,19 @@
tree[i] = 2*i
return tree
- def testNormal(self):
+ def test_normal(self):
# Looks like (state, first_bucket)
# where state looks like (bucket0, 15, bucket1).
- from BTrees.check import check
tree = self._makeOne()
state = tree.__getstate__()
self.assertEqual(len(state), 2)
self.assertEqual(len(state[0]), 3)
self.assertEqual(state[0][1], 15)
tree._check() # shouldn't blow up
- check(tree) # shouldn't blow up
+ self._callFUT(tree) # shouldn't blow up
- def testKeyTooLarge(self):
+ def test_key_too_large(self):
# Damage an invariant by dropping the BTree key to 14.
- from BTrees.check import check
tree = self._makeOne()
state = tree.__getstate__()
news = (state[0][0], 14, state[0][2]), state[1]
@@ -47,15 +47,14 @@
tree._check() # not caught
try:
# Expecting "... key %r >= upper bound %r at index %d"
- check(tree)
+ self._callFUT(tree)
except AssertionError as detail:
self.assertTrue(">= upper bound" in str(detail))
else:
self.fail("expected check(tree) to catch the problem")
- def testKeyTooSmall(self):
+ def test_key_too_small(self):
# Damage an invariant by bumping the BTree key to 16.
- from BTrees.check import check
tree = self._makeOne()
state = tree.__getstate__()
news = (state[0][0], 16, state[0][2]), state[1]
@@ -63,15 +62,14 @@
tree._check() # not caught
try:
# Expecting "... key %r < lower bound %r at index %d"
- check(tree)
+ self._callFUT(tree)
except AssertionError as detail:
self.assertTrue("< lower bound" in str(detail))
else:
self.fail("expected check(tree) to catch the problem")
- def testKeysSwapped(self):
+ def test_keys_swapped(self):
# Damage an invariant by swapping two key/value pairs.
- from BTrees.check import check
tree = self._makeOne()
state = tree.__getstate__()
# Looks like (state, first_bucket)
@@ -92,12 +90,13 @@
b0.__setstate__((newpairs, nextbucket))
tree._check() # not caught
try:
- check(tree)
+ self._callFUT(tree)
except AssertionError, detail:
self.assertTrue(
"key 5 at index 4 >= key 4 at index 5" in str(detail))
else:
self.fail("expected check(tree) to catch the problem")
+
def test_suite():
- return unittest.makeSuite(CheckTest)
+ return unittest.makeSuite(Test_check)
More information about the checkins
mailing list