Commit 47c2706e authored by Chris McDonough's avatar Chris McDonough

checked in some more typing tests for sets and buckets.

parent 06cf5863
...@@ -95,7 +95,9 @@ from BTrees.OOBTree import OOBTree, OOBucket, OOSet, OOTreeSet ...@@ -95,7 +95,9 @@ from BTrees.OOBTree import OOBTree, OOBucket, OOSet, OOTreeSet
from BTrees.IOBTree import IOBTree, IOBucket, IOSet, IOTreeSet from BTrees.IOBTree import IOBTree, IOBucket, IOSet, IOTreeSet
from BTrees.IIBTree import IIBTree, IIBucket, IISet, IITreeSet from BTrees.IIBTree import IIBTree, IIBucket, IISet, IITreeSet
from BTrees.OIBTree import OIBTree, OIBucket, OISet, OITreeSet from BTrees.OIBTree import OIBTree, OIBucket, OISet, OITreeSet
from unittest import TestCase, TestSuite, TextTestRunner, makeSuite from unittest import TestCase, TestSuite, JUnitTextTestRunner, VerboseTextTestRunner, makeSuite
TextTestRunner = VerboseTextTestRunner
class Base: class Base:
""" Tests common to all types: sets, buckets, and BTrees """ """ Tests common to all types: sets, buckets, and BTrees """
...@@ -574,7 +576,6 @@ class BTreeTests(MappingBase): ...@@ -574,7 +576,6 @@ class BTreeTests(MappingBase):
assert t.insert(1, 1) == 1 assert t.insert(1, 1) == 1
assert lsubtract(list(t.keys()), [0,1]) == [] assert lsubtract(list(t.keys()), [0,1]) == []
## BTree tests ## BTree tests
class TestIOBTrees(BTreeTests, TestCase): class TestIOBTrees(BTreeTests, TestCase):
...@@ -584,6 +585,7 @@ class TestIOBTrees(BTreeTests, TestCase): ...@@ -584,6 +585,7 @@ class TestIOBTrees(BTreeTests, TestCase):
def nonIntegerKeyRaises(self): def nonIntegerKeyRaises(self):
self.assertRaises(TypeError, self._stringraises) self.assertRaises(TypeError, self._stringraises)
self.assertRaises(TypeError, self._floatraises) self.assertRaises(TypeError, self._floatraises)
self.assertRaises(TypeError, self._noneraises)
def _stringraises(self): def _stringraises(self):
self.t['c'] = 1 self.t['c'] = 1
...@@ -591,6 +593,9 @@ class TestIOBTrees(BTreeTests, TestCase): ...@@ -591,6 +593,9 @@ class TestIOBTrees(BTreeTests, TestCase):
def _floatraises(self): def _floatraises(self):
self.t[2.5] = 1 self.t[2.5] = 1
def _noneraises(self):
self.t[None] = 1
class TestOOBTrees(BTreeTests, TestCase): class TestOOBTrees(BTreeTests, TestCase):
def setUp(self): def setUp(self):
self.t = OOBTree() self.t = OOBTree()
...@@ -599,26 +604,72 @@ class TestOIBTrees(BTreeTests, TestCase): ...@@ -599,26 +604,72 @@ class TestOIBTrees(BTreeTests, TestCase):
def setUp(self): def setUp(self):
self.t = OIBTree() self.t = OIBTree()
def testNonIntegerValueRaises(self):
self.assertRaises(TypeError, self._stringraises)
self.assertRaises(TypeError, self._floatraises)
self.assertRaises(TypeError, self._noneraises)
def _stringraises(self):
self.t[1] = 'c'
def _floatraises(self):
self.t[1] = 1.4
def _noneraises(self):
self.t[1] = None
class TestIIBTrees(BTreeTests, TestCase): class TestIIBTrees(BTreeTests, TestCase):
def setUp(self): def setUp(self):
self.t = IIBTree() self.t = IIBTree()
def nonIntegerKeyRaises(self): def testNonIntegerKeyRaises(self):
self.assertRaises(TypeError, self._stringraises) self.assertRaises(TypeError, self._stringraiseskey)
self.assertRaises(TypeError, self._floatraises) self.assertRaises(TypeError, self._floatraiseskey)
self.assertRaises(TypeError, self._noneraiseskey)
def _stringraises(self): def testNonIntegerValueRaises(self):
self.assertRaises(TypeError, self._stringraisesvalue)
self.assertRaises(TypeError, self._floatraisesvalue)
self.assertRaises(TypeError, self._noneraisesvalue)
def _stringraiseskey(self):
self.t['c'] = 1 self.t['c'] = 1
def _floatraises(self): def _floatraiseskey(self):
self.t[2.5] = 1 self.t[2.5] = 1
def _noneraiseskey(self):
self.t[None] = 1
def _stringraisesvalue(self):
self.t[1] = 'c'
def _floatraisesvalue(self):
self.t[1] = 1.4
def _noneraisesvalue(self):
self.t[1] = None
## Set tests ## Set tests
class TestIOSets(ExtendedSetTests, TestCase): class TestIOSets(ExtendedSetTests, TestCase):
def setUp(self): def setUp(self):
self.t = IOSet() self.t = IOSet()
def testNonIntegerInsertRaises(self):
self.assertRaises(TypeError,self._insertstringraises)
self.assertRaises(TypeError,self._insertfloatraises)
self.assertRaises(TypeError,self._insertnoneraises)
def _insertstringraises(self):
self.t.insert('a')
def _insertfloatraises(self):
self.t.insert(1.4)
def _insertnoneraises(self):
self.t.insert(None)
class TestOOSets(ExtendedSetTests, TestCase): class TestOOSets(ExtendedSetTests, TestCase):
def setUp(self): def setUp(self):
self.t = OOSet() self.t = OOSet()
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment