Ejemplo n.º 1
0
    def test_recursion(self):
        # Check that comparison for recursive objects fails gracefully
        from collections import UserList
        a = UserList()
        b = UserList()
        a.append(b)
        b.append(a)
        self.assertRaises(RecursionError, operator.eq, a, b)
        self.assertRaises(RecursionError, operator.ne, a, b)
        self.assertRaises(RecursionError, operator.lt, a, b)
        self.assertRaises(RecursionError, operator.le, a, b)
        self.assertRaises(RecursionError, operator.gt, a, b)
        self.assertRaises(RecursionError, operator.ge, a, b)

        b.append(17)
        # Even recursive lists of different lengths are different,
        # but they cannot be ordered
        self.assertTrue(not (a == b))
        self.assertTrue(a != b)
        self.assertRaises(RecursionError, operator.lt, a, b)
        self.assertRaises(RecursionError, operator.le, a, b)
        self.assertRaises(RecursionError, operator.gt, a, b)
        self.assertRaises(RecursionError, operator.ge, a, b)
        a.append(17)
        self.assertRaises(RecursionError, operator.eq, a, b)
        self.assertRaises(RecursionError, operator.ne, a, b)
        a.insert(0, 11)
        b.insert(0, 12)
        self.assertTrue(not (a == b))
        self.assertTrue(a != b)
        self.assertTrue(a < b)
Ejemplo n.º 2
0
    def test_recursion(self):
        # Check that comparison for recursive objects fails gracefully
        from collections import UserList
        a = UserList()
        b = UserList()
        a.append(b)
        b.append(a)
        self.assertRaises(RuntimeError, operator.eq, a, b)
        self.assertRaises(RuntimeError, operator.ne, a, b)
        self.assertRaises(RuntimeError, operator.lt, a, b)
        self.assertRaises(RuntimeError, operator.le, a, b)
        self.assertRaises(RuntimeError, operator.gt, a, b)
        self.assertRaises(RuntimeError, operator.ge, a, b)

        b.append(17)
        # Even recursive lists of different lengths are different,
        # but they cannot be ordered
        self.assertTrue(not (a == b))
        self.assertTrue(a != b)
        self.assertRaises(RuntimeError, operator.lt, a, b)
        self.assertRaises(RuntimeError, operator.le, a, b)
        self.assertRaises(RuntimeError, operator.gt, a, b)
        self.assertRaises(RuntimeError, operator.ge, a, b)
        a.append(17)
        self.assertRaises(RuntimeError, operator.eq, a, b)
        self.assertRaises(RuntimeError, operator.ne, a, b)
        a.insert(0, 11)
        b.insert(0, 12)
        self.assertTrue(not (a == b))
        self.assertTrue(a != b)
        self.assertTrue(a < b)
Ejemplo n.º 3
0
 def test_recursion(self):
     from collections import UserList
     a = UserList()
     b = UserList()
     a.append(b)
     b.append(a)
     self.assertRaises(RecursionError, operator.eq, a, b)
     self.assertRaises(RecursionError, operator.ne, a, b)
     self.assertRaises(RecursionError, operator.lt, a, b)
     self.assertRaises(RecursionError, operator.le, a, b)
     self.assertRaises(RecursionError, operator.gt, a, b)
     self.assertRaises(RecursionError, operator.ge, a, b)
     b.append(17)
     self.assertTrue(not a == b)
     self.assertTrue(a != b)
     self.assertRaises(RecursionError, operator.lt, a, b)
     self.assertRaises(RecursionError, operator.le, a, b)
     self.assertRaises(RecursionError, operator.gt, a, b)
     self.assertRaises(RecursionError, operator.ge, a, b)
     a.append(17)
     self.assertRaises(RecursionError, operator.eq, a, b)
     self.assertRaises(RecursionError, operator.ne, a, b)
     a.insert(0, 11)
     b.insert(0, 12)
     self.assertTrue(not a == b)
     self.assertTrue(a != b)
     self.assertTrue(a < b)
Ejemplo n.º 4
0
Archivo: Util.py Proyecto: billynip/map
 def insert(self, i):
     UserList.insert(self, i)
     self.unique = False
Ejemplo n.º 5
0
 def insert(self, i):
     UserList.insert(self, i)
     self.unique = False
Ejemplo n.º 6
0
	def insert(self, i, item):
		UserList.insert(self, i, item)
		self._changed()
Ejemplo n.º 7
0
 def insert(self, *args):
     UserList.insert(*args)
     self._update()
Ejemplo n.º 8
0
 def insert(self, *args):
     UserList.insert(*args)
     self._update()
Ejemplo n.º 9
0
 def insert(self, i, item):
     UserList.insert(self, i, item)
     self.send(insert=(i,item))
Ejemplo n.º 10
0
 def insert(self, i, item):
     UserList.insert(self, i, item)
     self.notify()