Back to index

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

List of all members.

Public Member Functions

def test_dicts

Detailed Description

Definition at line 255 of file test_richcmp.py.


Member Function Documentation

Definition at line 257 of file test_richcmp.py.

00257 
00258     def test_dicts(self):
00259         # Verify that __eq__ and __ne__ work for dicts even if the keys and
00260         # values don't support anything other than __eq__ and __ne__ (and
00261         # __hash__).  Complex numbers are a fine example of that.
00262         import random
00263         imag1a = {}
00264         for i in range(50):
00265             imag1a[random.randrange(100)*1j] = random.randrange(100)*1j
00266         items = list(imag1a.items())
00267         random.shuffle(items)
00268         imag1b = {}
00269         for k, v in items:
00270             imag1b[k] = v
00271         imag2 = imag1b.copy()
00272         imag2[k] = v + 1.0
00273         self.assertEqual(imag1a, imag1a)
00274         self.assertEqual(imag1a, imag1b)
00275         self.assertEqual(imag2, imag2)
00276         self.assertTrue(imag1a != imag2)
00277         for opname in ("lt", "le", "gt", "ge"):
00278             for op in opmap[opname]:
00279                 self.assertRaises(TypeError, op, imag1a, imag2)

Here is the call graph for this function:


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