Skip to content

Commit

Permalink
test_iterlist: additional tests for LessThan
Browse files Browse the repository at this point in the history
  • Loading branch information
masenf committed Jan 27, 2020
1 parent e6a5af3 commit de7e16d
Showing 1 changed file with 60 additions and 3 deletions.
63 changes: 60 additions & 3 deletions tests/test_iterlist.py
Original file line number Diff line number Diff line change
Expand Up @@ -268,9 +268,15 @@ def test_with_str(self):

def test_with_non_iterable(self):
a = iterlist.IterList([])
b = 0
self.assertFalse(a == b)
self.assertTrue(a != b)
b = iterlist.IterTuple([])
c = iterlist.CachedIterator([])
d = 0
self.assertFalse(a == d)
self.assertTrue(a != d)
self.assertFalse(b == d)
self.assertTrue(b != d)
self.assertFalse(c == d)
self.assertTrue(c != d)

def test_with_bare_iterable(self):
a = iterlist.IterList(range(range_size))
Expand Down Expand Up @@ -420,6 +426,57 @@ def test_unordered(self):
self.assertTrue(a < b)
self.assertFalse(b < a)

def test_with_list(self):
a = iterlist.IterList(range(range_size))
b = iterlist.IterTuple(range(range_size))
c = list(range(-1, range_size-1))
d = list(range(1, range_size+1))
e = list(range(range_size))
self.assertTrue(a < d)
self.assertFalse(a < c)
self.assertFalse(a < e)
# cannot compare IterList and tuple
with self.assertRaises(TypeError):
self.assertTrue(b < d)
with self.assertRaises(TypeError):
self.assertFalse(b < c)
with self.assertRaises(TypeError):
self.assertFalse(b < e)
try:
self.assertFalse(d < a)
# XXX: doesn't actually do less than, always False
self.assertFalse(c < a)
self.assertFalse(e < a)
except TypeError:
# cannot compare list and IterList on py3
pass

def test_with_tuple(self):
a = iterlist.IterTuple(range(range_size))
b = iterlist.IterList(range(range_size))
c = tuple(range(-1, range_size-1))
d = tuple(range(1, range_size+1))
e = tuple(range(range_size))
self.assertTrue(a < d)
self.assertFalse(a < c)
self.assertFalse(a < e)
# cannot compare IterList and tuple
with self.assertRaises(TypeError):
self.assertTrue(b < d)
with self.assertRaises(TypeError):
self.assertFalse(b < c)
with self.assertRaises(TypeError):
self.assertFalse(b < e)
try:
self.assertFalse(d < a)
# XXX: doesn't actually do less than, always False
self.assertFalse(c < a)
self.assertFalse(e < a)
except TypeError:
# cannot compare tuple and IterTuple on py3
pass



class TestIter(unittest.TestCase):
def test_iter_unconsumed(self):
Expand Down

0 comments on commit de7e16d

Please sign in to comment.