Back to index

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

List of all members.

Public Member Functions

def checkfail
def checkequal
def test_mixed

Detailed Description

Definition at line 96 of file

Member Function Documentation

def test.test_richcmp.VectorTest.checkequal (   self,

Definition at line 102 of file

00103     def checkequal(self, opname, a, b, expres):
00104         for op in opmap[opname]:
00105             realres = op(a, b)
00106             # can't use assertEqual(realres, expres) here
00107             self.assertEqual(len(realres), len(expres))
00108             for i in range(len(realres)):
00109                 # results are bool, so we can use "is" here
00110                 self.assertTrue(realres[i] is expres[i])

Here is the call graph for this function:

Here is the caller graph for this function:

def test.test_richcmp.VectorTest.checkfail (   self,

Definition at line 98 of file

00099     def checkfail(self, error, opname, *args):
00100         for op in opmap[opname]:
00101             self.assertRaises(error, op, *args)

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 111 of file

00112     def test_mixed(self):
00113         # check that comparisons involving Vector objects
00114         # which return rich results (i.e. Vectors with itemwise
00115         # comparison results) work
00116         a = Vector(range(2))
00117         b = Vector(range(3))
00118         # all comparisons should fail for different length
00119         for opname in opmap:
00120             self.checkfail(ValueError, opname, a, b)
00122         a = list(range(5))
00123         b = 5 * [2]
00124         # try mixed arguments (but not (a, b) as that won't return a bool vector)
00125         args = [(a, Vector(b)), (Vector(a), b), (Vector(a), Vector(b))]
00126         for (a, b) in args:
00127             self.checkequal("lt", a, b, [True,  True,  False, False, False])
00128             self.checkequal("le", a, b, [True,  True,  True,  False, False])
00129             self.checkequal("eq", a, b, [False, False, True,  False, False])
00130             self.checkequal("ne", a, b, [True,  True,  False, True,  True ])
00131             self.checkequal("gt", a, b, [False, False, False, True,  True ])
00132             self.checkequal("ge", a, b, [False, False, True,  True,  True ])
00134             for ops in opmap.values():
00135                 for op in ops:
00136                     # calls __bool__, which should fail
00137                     self.assertRaises(TypeError, bool, op(a, b))

Here is the call graph for this function:

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