(self)
| 217 | @support.no_tracing |
| 218 | @support.infinite_recursion(25) |
| 219 | def test_recursion(self): |
| 220 | # Check that comparison for recursive objects fails gracefully |
| 221 | from collections import UserList |
| 222 | a = UserList() |
| 223 | b = UserList() |
| 224 | a.append(b) |
| 225 | b.append(a) |
| 226 | self.assertRaises(RecursionError, operator.eq, a, b) |
| 227 | self.assertRaises(RecursionError, operator.ne, a, b) |
| 228 | self.assertRaises(RecursionError, operator.lt, a, b) |
| 229 | self.assertRaises(RecursionError, operator.le, a, b) |
| 230 | self.assertRaises(RecursionError, operator.gt, a, b) |
| 231 | self.assertRaises(RecursionError, operator.ge, a, b) |
| 232 | |
| 233 | b.append(17) |
| 234 | # Even recursive lists of different lengths are different, |
| 235 | # but they cannot be ordered |
| 236 | self.assertTrue(not (a == b)) |
| 237 | self.assertTrue(a != b) |
| 238 | self.assertRaises(RecursionError, operator.lt, a, b) |
| 239 | self.assertRaises(RecursionError, operator.le, a, b) |
| 240 | self.assertRaises(RecursionError, operator.gt, a, b) |
| 241 | self.assertRaises(RecursionError, operator.ge, a, b) |
| 242 | a.append(17) |
| 243 | self.assertRaises(RecursionError, operator.eq, a, b) |
| 244 | self.assertRaises(RecursionError, operator.ne, a, b) |
| 245 | a.insert(0, 11) |
| 246 | b.insert(0, 12) |
| 247 | self.assertTrue(not (a == b)) |
| 248 | self.assertTrue(a != b) |
| 249 | self.assertTrue(a < b) |
| 250 | |
| 251 | def test_exception_message(self): |
| 252 | class Spam: |
nothing calls this directly
no test coverage detected