Permalink
Browse files

Added many more tests for the sorted set and list types

  • Loading branch information...
1 parent b1cc8ed commit a95366a45d3027ae63265cc05080fdb5ec96ebc8 @DanielStutzbach committed May 20, 2010
Showing with 1,840 additions and 114 deletions.
  1. +7 −0 .coveragerc
  2. +14 −10 test/btuple_tests.py
  3. +3 −3 test/list_tests.py
  4. +9 −8 test/mapping_tests.py
  5. +3 −3 test/seq_tests.py
  6. +1 −1 test/sorteddict_tests.py
  7. +253 −85 test/sortedlist_tests.py
  8. +1,530 −0 test/test_set.py
  9. +15 −0 test/unittest.py
  10. +5 −4 test_blist.py
View
@@ -0,0 +1,7 @@
+[run]
+branch = True
+
+[report]
+omit:
+ test/unittest
+ test/test_support
View
@@ -93,18 +93,22 @@ def test_repr(self):
self.assertEqual(repr(a2), "btuple((0, 1, 2))")
def _not_tracked(self, t):
- if sys.version_info[0] < 3: return
- # Nested tuples can take several collections to untrack
- gc.collect()
- gc.collect()
- self.assertFalse(gc.is_tracked(t), t)
+ if sys.version_info[0] < 3:
+ return
+ else: # pragma: no cover
+ # Nested tuples can take several collections to untrack
+ gc.collect()
+ gc.collect()
+ self.assertFalse(gc.is_tracked(t), t)
def _tracked(self, t):
- if sys.version_info[0] < 3: return
- self.assertTrue(gc.is_tracked(t), t)
- gc.collect()
- gc.collect()
- self.assertTrue(gc.is_tracked(t), t)
+ if sys.version_info[0] < 3:
+ return
+ else: # pragma: no cover
+ self.assertTrue(gc.is_tracked(t), t)
+ gc.collect()
+ gc.collect()
+ self.assertTrue(gc.is_tracked(t), t)
def test_track_literals(self):
# Test GC-optimization of tuple literals
View
@@ -91,9 +91,9 @@ def test_reversed(self):
a = self.type2test(list(range(20)))
r = reversed(a)
self.assertEqual(list(r), self.type2test(list(range(19, -1, -1))))
- if hasattr(r, '__next__'):
+ if hasattr(r, '__next__'): # pragma: no cover
self.assertRaises(StopIteration, r.__next__)
- else:
+ else: # pragma: no cover
self.assertRaises(StopIteration, r.next)
self.assertEqual(list(reversed(self.type2test())),
self.type2test())
@@ -444,7 +444,7 @@ def test_sort(self):
a.sort()
self.assertEqual(a, self.type2test(list(range(512))))
- def revcmp(a, b):
+ def revcmp(a, b): # pragma: no cover
if a == b:
return 0
elif a < b:
View
@@ -16,7 +16,7 @@ class BasicTestMappingProtocol(unittest.TestCase):
# semantics
type2test = None # which class is being tested (overwrite in subclasses)
- def _reference(self):
+ def _reference(self): # pragma: no cover
"""Return a dictionary of values which are invariant by storage
in the object under test."""
return {1:2, "key1":"value1", "key2":(1,2,3)}
@@ -49,7 +49,7 @@ def test_read(self):
p = self._empty_mapping()
p1 = dict(p) #workaround for singleton objects
d = self._full_mapping(self.reference)
- if d is p:
+ if d is p: # pragma: no cover
p = p1
#Indexing
for key, value in self.reference.items():
@@ -74,9 +74,9 @@ def test_read(self):
if not d: self.fail("Full mapping must compare to True")
# keys(), items(), iterkeys() ...
def check_iterandlist(iter, lst, ref):
- if sys.version_info[0] < 3:
+ if sys.version_info[0] < 3: # pragma: no cover
self.assert_(hasattr(iter, 'next'))
- else:
+ else: # pragma: no cover
self.assert_(hasattr(iter, '__next__'))
self.assert_(hasattr(iter, '__iter__'))
x = list(iter)
@@ -256,7 +256,8 @@ def __next__(self):
rtn = chr(self.i)
self.i += 1
return rtn
- raise StopIteration
+ else: # pragma: no cover
+ raise StopIteration
next = __next__
return BogonIter()
def __getitem__(self, key):
@@ -559,7 +560,7 @@ def test_getitem(self):
class Exc(Exception): pass
class BadEq(object):
- def __eq__(self, other):
+ def __eq__(self, other): # pragma: no cover
raise Exc()
def __hash__(self):
return 24
@@ -610,7 +611,7 @@ def __hash__(self):
x.fail = True
self.assertRaises(Exc, d.pop, x)
- def test_mutatingiteration(self):
+ def test_mutatingiteration(self): # pragma: no cover
d = self._empty_mapping()
d[1] = 1
try:
@@ -621,7 +622,7 @@ def test_mutatingiteration(self):
else:
self.fail("changing dict size during iteration doesn't raise Error")
- def test_repr(self):
+ def test_repr(self): # pragma: no cover
d = self._empty_mapping()
self.assertEqual(repr(d), '{}')
d[1] = 2
View
@@ -51,7 +51,7 @@ class IterNextOnly:
def __init__(self, seqn):
self.seqn = seqn
self.i = 0
- def __next__(self):
+ def __next__(self): # pragma: no cover
if self.i >= len(self.seqn): raise StopIteration
v = self.seqn[self.i]
self.i += 1
@@ -223,7 +223,7 @@ class AllEq:
# So instances of AllEq must be found in all non-empty sequences.
def __eq__(self, other):
return True
- def __hash__(self):
+ def __hash__(self): # pragma: no cover
raise NotImplemented
self.assert_(AllEq() not in self.type2test([]))
self.assert_(AllEq() in self.type2test([1]))
@@ -303,7 +303,7 @@ def test_imul(self):
def test_getitemoverwriteiter(self):
# Verify that __getitem__ overrides are not recognized by __iter__
class T(self.type2test):
- def __getitem__(self, key):
+ def __getitem__(self, key): # pragma: no cover
return str(key) + '!!!'
self.assertEqual(next(iter(T((1,2)))), 1)
View
@@ -50,7 +50,7 @@ def test_sort(self):
a = self.type2test.fromkeys(reversed(list(range(512))))
self.assertEqual(list(a.keys()), list(range(512)))
- def revcmp(a, b):
+ def revcmp(a, b): # pragma: no cover
if a == b:
return 0
elif a < b:
Oops, something went wrong.

0 comments on commit a95366a

Please sign in to comment.