Back to index

python3.2  3.2.2
Public Member Functions
test.test_richcmp.ListTest Class Reference

List of all members.

Public Member Functions

def test_coverage
def test_badentry
def test_goodentry

Detailed Description

Definition at line 280 of file test_richcmp.py.


Member Function Documentation

Definition at line 299 of file test_richcmp.py.

00299 
00300     def test_badentry(self):
00301         # make sure that exceptions for item comparison are properly
00302         # propagated in list comparisons
00303         class Exc(Exception):
00304             pass
00305         class Bad:
00306             def __eq__(self, other):
00307                 raise Exc
00308 
00309         x = [Bad()]
00310         y = [Bad()]
00311 
00312         for op in opmap["eq"]:
00313             self.assertRaises(Exc, op, x, y)

Definition at line 282 of file test_richcmp.py.

00282 
00283     def test_coverage(self):
00284         # exercise all comparisons for lists
00285         x = [42]
00286         self.assertIs(x<x, False)
00287         self.assertIs(x<=x, True)
00288         self.assertIs(x==x, True)
00289         self.assertIs(x!=x, False)
00290         self.assertIs(x>x, False)
00291         self.assertIs(x>=x, True)
00292         y = [42, 42]
00293         self.assertIs(x<y, True)
00294         self.assertIs(x<=y, True)
00295         self.assertIs(x==y, False)
00296         self.assertIs(x!=y, True)
00297         self.assertIs(x>y, False)
00298         self.assertIs(x>=y, False)

Here is the call graph for this function:

Definition at line 314 of file test_richcmp.py.

00314 
00315     def test_goodentry(self):
00316         # This test exercises the final call to PyObject_RichCompare()
00317         # in Objects/listobject.c::list_richcompare()
00318         class Good:
00319             def __lt__(self, other):
00320                 return True
00321 
00322         x = [Good()]
00323         y = [Good()]
00324 
00325         for op in opmap["lt"]:
00326             self.assertIs(op(x, y), True)
00327 

Here is the call graph for this function:


The documentation for this class was generated from the following file: