Back to index

python3.2  3.2.2
Public Member Functions
test.test_functools.TestCmpToKey Class Reference

List of all members.

Public Member Functions

def test_cmp_to_key
def test_hash

Detailed Description

Definition at line 438 of file test_functools.py.


Member Function Documentation

Definition at line 439 of file test_functools.py.

00439 
00440     def test_cmp_to_key(self):
00441         def mycmp(x, y):
00442             return y - x
00443         self.assertEqual(sorted(range(5), key=functools.cmp_to_key(mycmp)),
00444                          [4, 3, 2, 1, 0])

Here is the call graph for this function:

Definition at line 445 of file test_functools.py.

00445 
00446     def test_hash(self):
00447         def mycmp(x, y):
00448             return y - x
00449         key = functools.cmp_to_key(mycmp)
00450         k = key(10)
00451         self.assertRaises(TypeError, hash, k)
00452         self.assertFalse(isinstance(k, collections.Hashable))

Here is the call graph for this function:


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