annotate Lib/test/test_hash.py @ 78069:a8aa77458e12 3.2

Add c_size_t and c_ssize_t to the ctypes summary table.
author Antoine Pitrou <solipsis@pitrou.net>
date Thu, 12 Jul 2012 20:31:50 +0200
parents eb46c8f44aae
children 90d302951add
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
13141
cca84745da3e This patch addresses two main issues: (1) There exist some non-fatal
Fred Drake <fdrake@acm.org>
parents:
diff changeset
1 # test the invariant that
cca84745da3e This patch addresses two main issues: (1) There exist some non-fatal
Fred Drake <fdrake@acm.org>
parents:
diff changeset
2 # iff a==b then hash(a)==hash(b)
cca84745da3e This patch addresses two main issues: (1) There exist some non-fatal
Fred Drake <fdrake@acm.org>
parents:
diff changeset
3 #
48475
f4e7ef4329a9 Manual forward port of 64962 - use PyObject_HashNotImplemented as a tp_hash level indicator that the default hash implementation has not been inherited
Nick Coghlan <ncoghlan@gmail.com>
parents: 47201
diff changeset
4 # Also test that hash implementations are inherited as expected
13141
cca84745da3e This patch addresses two main issues: (1) There exist some non-fatal
Fred Drake <fdrake@acm.org>
parents:
diff changeset
5
75066
f4b7ecf8a5f8 Issue #13703: add a way to randomize the hash values of basic types (str, bytes, datetime)
Georg Brandl <georg@python.org>
parents: 55593
diff changeset
6 import datetime
f4b7ecf8a5f8 Issue #13703: add a way to randomize the hash values of basic types (str, bytes, datetime)
Georg Brandl <georg@python.org>
parents: 55593
diff changeset
7 import os
75073
4a31f6b11e7a Merge from 3.1: Issue #13703: add a way to randomize the hash values of basic types (str, bytes, datetime)
Georg Brandl <georg@python.org>
parents: 58473 75066
diff changeset
8 import sys
17859
b77c4888d7cc Simple conversion to PyUnit.
Fred Drake <fdrake@acm.org>
parents: 15305
diff changeset
9 import unittest
47201
9c930a32cebb #2621 rename test.test_support to test.support
Benjamin Peterson <benjamin@python.org>
parents: 43410
diff changeset
10 from test import support
75066
f4b7ecf8a5f8 Issue #13703: add a way to randomize the hash values of basic types (str, bytes, datetime)
Georg Brandl <georg@python.org>
parents: 55593
diff changeset
11 from test.script_helper import assert_python_ok
48475
f4e7ef4329a9 Manual forward port of 64962 - use PyObject_HashNotImplemented as a tp_hash level indicator that the default hash implementation has not been inherited
Nick Coghlan <ncoghlan@gmail.com>
parents: 47201
diff changeset
12 from collections import Hashable
13141
cca84745da3e This patch addresses two main issues: (1) There exist some non-fatal
Fred Drake <fdrake@acm.org>
parents:
diff changeset
13
75073
4a31f6b11e7a Merge from 3.1: Issue #13703: add a way to randomize the hash values of basic types (str, bytes, datetime)
Georg Brandl <georg@python.org>
parents: 58473 75066
diff changeset
14 IS_64BIT = sys.maxsize > 2**32
75066
f4b7ecf8a5f8 Issue #13703: add a way to randomize the hash values of basic types (str, bytes, datetime)
Georg Brandl <georg@python.org>
parents: 55593
diff changeset
15
13141
cca84745da3e This patch addresses two main issues: (1) There exist some non-fatal
Fred Drake <fdrake@acm.org>
parents:
diff changeset
16
17859
b77c4888d7cc Simple conversion to PyUnit.
Fred Drake <fdrake@acm.org>
parents: 15305
diff changeset
17 class HashEqualityTestCase(unittest.TestCase):
b77c4888d7cc Simple conversion to PyUnit.
Fred Drake <fdrake@acm.org>
parents: 15305
diff changeset
18
b77c4888d7cc Simple conversion to PyUnit.
Fred Drake <fdrake@acm.org>
parents: 15305
diff changeset
19 def same_hash(self, *objlist):
17860
b53b60f1ed45 Update a comment.
Fred Drake <fdrake@acm.org>
parents: 17859
diff changeset
20 # Hash each object given and fail if
b53b60f1ed45 Update a comment.
Fred Drake <fdrake@acm.org>
parents: 17859
diff changeset
21 # the hash values are not all the same.
42142
a53e48be6df9 Merged revisions 56125-56153 via svnmerge from
Guido van Rossum <guido@python.org>
parents: 40644
diff changeset
22 hashed = list(map(hash, objlist))
17859
b77c4888d7cc Simple conversion to PyUnit.
Fred Drake <fdrake@acm.org>
parents: 15305
diff changeset
23 for h in hashed[1:]:
b77c4888d7cc Simple conversion to PyUnit.
Fred Drake <fdrake@acm.org>
parents: 15305
diff changeset
24 if h != hashed[0]:
31515
71a294bd7950 Replace backticks with repr() or "%r"
Walter Dörwald <walter@livinglogic.de>
parents: 24364
diff changeset
25 self.fail("hashed values differ: %r" % (objlist,))
17859
b77c4888d7cc Simple conversion to PyUnit.
Fred Drake <fdrake@acm.org>
parents: 15305
diff changeset
26
b77c4888d7cc Simple conversion to PyUnit.
Fred Drake <fdrake@acm.org>
parents: 15305
diff changeset
27 def test_numeric_literals(self):
40644
1c26505c1de6 Rip out 'long' and 'L'-suffixed integer literals.
Guido van Rossum <guido@python.org>
parents: 31515
diff changeset
28 self.same_hash(1, 1, 1.0, 1.0+0.0j)
43410
b06b191b7cfa Merged revisions 58203-58210 via svnmerge from
Thomas Wouters <thomas@python.org>
parents: 42142
diff changeset
29 self.same_hash(0, 0.0, 0.0+0.0j)
b06b191b7cfa Merged revisions 58203-58210 via svnmerge from
Thomas Wouters <thomas@python.org>
parents: 42142
diff changeset
30 self.same_hash(-1, -1.0, -1.0+0.0j)
b06b191b7cfa Merged revisions 58203-58210 via svnmerge from
Thomas Wouters <thomas@python.org>
parents: 42142
diff changeset
31 self.same_hash(-2, -2.0, -2.0+0.0j)
17859
b77c4888d7cc Simple conversion to PyUnit.
Fred Drake <fdrake@acm.org>
parents: 15305
diff changeset
32
b77c4888d7cc Simple conversion to PyUnit.
Fred Drake <fdrake@acm.org>
parents: 15305
diff changeset
33 def test_coerced_integers(self):
40644
1c26505c1de6 Rip out 'long' and 'L'-suffixed integer literals.
Guido van Rossum <guido@python.org>
parents: 31515
diff changeset
34 self.same_hash(int(1), int(1), float(1), complex(1),
17859
b77c4888d7cc Simple conversion to PyUnit.
Fred Drake <fdrake@acm.org>
parents: 15305
diff changeset
35 int('1'), float('1.0'))
43410
b06b191b7cfa Merged revisions 58203-58210 via svnmerge from
Thomas Wouters <thomas@python.org>
parents: 42142
diff changeset
36 self.same_hash(int(-2**31), float(-2**31))
b06b191b7cfa Merged revisions 58203-58210 via svnmerge from
Thomas Wouters <thomas@python.org>
parents: 42142
diff changeset
37 self.same_hash(int(1-2**31), float(1-2**31))
b06b191b7cfa Merged revisions 58203-58210 via svnmerge from
Thomas Wouters <thomas@python.org>
parents: 42142
diff changeset
38 self.same_hash(int(2**31-1), float(2**31-1))
b06b191b7cfa Merged revisions 58203-58210 via svnmerge from
Thomas Wouters <thomas@python.org>
parents: 42142
diff changeset
39 # for 64-bit platforms
b06b191b7cfa Merged revisions 58203-58210 via svnmerge from
Thomas Wouters <thomas@python.org>
parents: 42142
diff changeset
40 self.same_hash(int(2**31), float(2**31))
b06b191b7cfa Merged revisions 58203-58210 via svnmerge from
Thomas Wouters <thomas@python.org>
parents: 42142
diff changeset
41 self.same_hash(int(-2**63), float(-2**63))
51424
811546770d20 Merged revisions 69392 via svnmerge from
Guilherme Polo <ggpolo@gmail.com>
parents: 51384
diff changeset
42 self.same_hash(int(2**63), float(2**63))
17859
b77c4888d7cc Simple conversion to PyUnit.
Fred Drake <fdrake@acm.org>
parents: 15305
diff changeset
43
b77c4888d7cc Simple conversion to PyUnit.
Fred Drake <fdrake@acm.org>
parents: 15305
diff changeset
44 def test_coerced_floats(self):
40644
1c26505c1de6 Rip out 'long' and 'L'-suffixed integer literals.
Guido van Rossum <guido@python.org>
parents: 31515
diff changeset
45 self.same_hash(int(1.23e300), float(1.23e300))
17859
b77c4888d7cc Simple conversion to PyUnit.
Fred Drake <fdrake@acm.org>
parents: 15305
diff changeset
46 self.same_hash(float(0.5), complex(0.5, 0.0))
13141
cca84745da3e This patch addresses two main issues: (1) There exist some non-fatal
Fred Drake <fdrake@acm.org>
parents:
diff changeset
47
cca84745da3e This patch addresses two main issues: (1) There exist some non-fatal
Fred Drake <fdrake@acm.org>
parents:
diff changeset
48
48475
f4e7ef4329a9 Manual forward port of 64962 - use PyObject_HashNotImplemented as a tp_hash level indicator that the default hash implementation has not been inherited
Nick Coghlan <ncoghlan@gmail.com>
parents: 47201
diff changeset
49 _default_hash = object.__hash__
f4e7ef4329a9 Manual forward port of 64962 - use PyObject_HashNotImplemented as a tp_hash level indicator that the default hash implementation has not been inherited
Nick Coghlan <ncoghlan@gmail.com>
parents: 47201
diff changeset
50 class DefaultHash(object): pass
f4e7ef4329a9 Manual forward port of 64962 - use PyObject_HashNotImplemented as a tp_hash level indicator that the default hash implementation has not been inherited
Nick Coghlan <ncoghlan@gmail.com>
parents: 47201
diff changeset
51
f4e7ef4329a9 Manual forward port of 64962 - use PyObject_HashNotImplemented as a tp_hash level indicator that the default hash implementation has not been inherited
Nick Coghlan <ncoghlan@gmail.com>
parents: 47201
diff changeset
52 _FIXED_HASH_VALUE = 42
f4e7ef4329a9 Manual forward port of 64962 - use PyObject_HashNotImplemented as a tp_hash level indicator that the default hash implementation has not been inherited
Nick Coghlan <ncoghlan@gmail.com>
parents: 47201
diff changeset
53 class FixedHash(object):
f4e7ef4329a9 Manual forward port of 64962 - use PyObject_HashNotImplemented as a tp_hash level indicator that the default hash implementation has not been inherited
Nick Coghlan <ncoghlan@gmail.com>
parents: 47201
diff changeset
54 def __hash__(self):
f4e7ef4329a9 Manual forward port of 64962 - use PyObject_HashNotImplemented as a tp_hash level indicator that the default hash implementation has not been inherited
Nick Coghlan <ncoghlan@gmail.com>
parents: 47201
diff changeset
55 return _FIXED_HASH_VALUE
f4e7ef4329a9 Manual forward port of 64962 - use PyObject_HashNotImplemented as a tp_hash level indicator that the default hash implementation has not been inherited
Nick Coghlan <ncoghlan@gmail.com>
parents: 47201
diff changeset
56
f4e7ef4329a9 Manual forward port of 64962 - use PyObject_HashNotImplemented as a tp_hash level indicator that the default hash implementation has not been inherited
Nick Coghlan <ncoghlan@gmail.com>
parents: 47201
diff changeset
57 class OnlyEquality(object):
f4e7ef4329a9 Manual forward port of 64962 - use PyObject_HashNotImplemented as a tp_hash level indicator that the default hash implementation has not been inherited
Nick Coghlan <ncoghlan@gmail.com>
parents: 47201
diff changeset
58 def __eq__(self, other):
f4e7ef4329a9 Manual forward port of 64962 - use PyObject_HashNotImplemented as a tp_hash level indicator that the default hash implementation has not been inherited
Nick Coghlan <ncoghlan@gmail.com>
parents: 47201
diff changeset
59 return self is other
f4e7ef4329a9 Manual forward port of 64962 - use PyObject_HashNotImplemented as a tp_hash level indicator that the default hash implementation has not been inherited
Nick Coghlan <ncoghlan@gmail.com>
parents: 47201
diff changeset
60
f4e7ef4329a9 Manual forward port of 64962 - use PyObject_HashNotImplemented as a tp_hash level indicator that the default hash implementation has not been inherited
Nick Coghlan <ncoghlan@gmail.com>
parents: 47201
diff changeset
61 class OnlyInequality(object):
f4e7ef4329a9 Manual forward port of 64962 - use PyObject_HashNotImplemented as a tp_hash level indicator that the default hash implementation has not been inherited
Nick Coghlan <ncoghlan@gmail.com>
parents: 47201
diff changeset
62 def __ne__(self, other):
f4e7ef4329a9 Manual forward port of 64962 - use PyObject_HashNotImplemented as a tp_hash level indicator that the default hash implementation has not been inherited
Nick Coghlan <ncoghlan@gmail.com>
parents: 47201
diff changeset
63 return self is not other
f4e7ef4329a9 Manual forward port of 64962 - use PyObject_HashNotImplemented as a tp_hash level indicator that the default hash implementation has not been inherited
Nick Coghlan <ncoghlan@gmail.com>
parents: 47201
diff changeset
64
f4e7ef4329a9 Manual forward port of 64962 - use PyObject_HashNotImplemented as a tp_hash level indicator that the default hash implementation has not been inherited
Nick Coghlan <ncoghlan@gmail.com>
parents: 47201
diff changeset
65 class InheritedHashWithEquality(FixedHash, OnlyEquality): pass
f4e7ef4329a9 Manual forward port of 64962 - use PyObject_HashNotImplemented as a tp_hash level indicator that the default hash implementation has not been inherited
Nick Coghlan <ncoghlan@gmail.com>
parents: 47201
diff changeset
66 class InheritedHashWithInequality(FixedHash, OnlyInequality): pass
f4e7ef4329a9 Manual forward port of 64962 - use PyObject_HashNotImplemented as a tp_hash level indicator that the default hash implementation has not been inherited
Nick Coghlan <ncoghlan@gmail.com>
parents: 47201
diff changeset
67
f4e7ef4329a9 Manual forward port of 64962 - use PyObject_HashNotImplemented as a tp_hash level indicator that the default hash implementation has not been inherited
Nick Coghlan <ncoghlan@gmail.com>
parents: 47201
diff changeset
68 class NoHash(object):
f4e7ef4329a9 Manual forward port of 64962 - use PyObject_HashNotImplemented as a tp_hash level indicator that the default hash implementation has not been inherited
Nick Coghlan <ncoghlan@gmail.com>
parents: 47201
diff changeset
69 __hash__ = None
f4e7ef4329a9 Manual forward port of 64962 - use PyObject_HashNotImplemented as a tp_hash level indicator that the default hash implementation has not been inherited
Nick Coghlan <ncoghlan@gmail.com>
parents: 47201
diff changeset
70
f4e7ef4329a9 Manual forward port of 64962 - use PyObject_HashNotImplemented as a tp_hash level indicator that the default hash implementation has not been inherited
Nick Coghlan <ncoghlan@gmail.com>
parents: 47201
diff changeset
71 class HashInheritanceTestCase(unittest.TestCase):
f4e7ef4329a9 Manual forward port of 64962 - use PyObject_HashNotImplemented as a tp_hash level indicator that the default hash implementation has not been inherited
Nick Coghlan <ncoghlan@gmail.com>
parents: 47201
diff changeset
72 default_expected = [object(),
f4e7ef4329a9 Manual forward port of 64962 - use PyObject_HashNotImplemented as a tp_hash level indicator that the default hash implementation has not been inherited
Nick Coghlan <ncoghlan@gmail.com>
parents: 47201
diff changeset
73 DefaultHash(),
f4e7ef4329a9 Manual forward port of 64962 - use PyObject_HashNotImplemented as a tp_hash level indicator that the default hash implementation has not been inherited
Nick Coghlan <ncoghlan@gmail.com>
parents: 47201
diff changeset
74 OnlyInequality(),
f4e7ef4329a9 Manual forward port of 64962 - use PyObject_HashNotImplemented as a tp_hash level indicator that the default hash implementation has not been inherited
Nick Coghlan <ncoghlan@gmail.com>
parents: 47201
diff changeset
75 ]
f4e7ef4329a9 Manual forward port of 64962 - use PyObject_HashNotImplemented as a tp_hash level indicator that the default hash implementation has not been inherited
Nick Coghlan <ncoghlan@gmail.com>
parents: 47201
diff changeset
76 fixed_expected = [FixedHash(),
f4e7ef4329a9 Manual forward port of 64962 - use PyObject_HashNotImplemented as a tp_hash level indicator that the default hash implementation has not been inherited
Nick Coghlan <ncoghlan@gmail.com>
parents: 47201
diff changeset
77 InheritedHashWithEquality(),
f4e7ef4329a9 Manual forward port of 64962 - use PyObject_HashNotImplemented as a tp_hash level indicator that the default hash implementation has not been inherited
Nick Coghlan <ncoghlan@gmail.com>
parents: 47201
diff changeset
78 InheritedHashWithInequality(),
f4e7ef4329a9 Manual forward port of 64962 - use PyObject_HashNotImplemented as a tp_hash level indicator that the default hash implementation has not been inherited
Nick Coghlan <ncoghlan@gmail.com>
parents: 47201
diff changeset
79 ]
f4e7ef4329a9 Manual forward port of 64962 - use PyObject_HashNotImplemented as a tp_hash level indicator that the default hash implementation has not been inherited
Nick Coghlan <ncoghlan@gmail.com>
parents: 47201
diff changeset
80 error_expected = [NoHash(),
f4e7ef4329a9 Manual forward port of 64962 - use PyObject_HashNotImplemented as a tp_hash level indicator that the default hash implementation has not been inherited
Nick Coghlan <ncoghlan@gmail.com>
parents: 47201
diff changeset
81 OnlyEquality(),
f4e7ef4329a9 Manual forward port of 64962 - use PyObject_HashNotImplemented as a tp_hash level indicator that the default hash implementation has not been inherited
Nick Coghlan <ncoghlan@gmail.com>
parents: 47201
diff changeset
82 ]
f4e7ef4329a9 Manual forward port of 64962 - use PyObject_HashNotImplemented as a tp_hash level indicator that the default hash implementation has not been inherited
Nick Coghlan <ncoghlan@gmail.com>
parents: 47201
diff changeset
83
f4e7ef4329a9 Manual forward port of 64962 - use PyObject_HashNotImplemented as a tp_hash level indicator that the default hash implementation has not been inherited
Nick Coghlan <ncoghlan@gmail.com>
parents: 47201
diff changeset
84 def test_default_hash(self):
f4e7ef4329a9 Manual forward port of 64962 - use PyObject_HashNotImplemented as a tp_hash level indicator that the default hash implementation has not been inherited
Nick Coghlan <ncoghlan@gmail.com>
parents: 47201
diff changeset
85 for obj in self.default_expected:
f4e7ef4329a9 Manual forward port of 64962 - use PyObject_HashNotImplemented as a tp_hash level indicator that the default hash implementation has not been inherited
Nick Coghlan <ncoghlan@gmail.com>
parents: 47201
diff changeset
86 self.assertEqual(hash(obj), _default_hash(obj))
f4e7ef4329a9 Manual forward port of 64962 - use PyObject_HashNotImplemented as a tp_hash level indicator that the default hash implementation has not been inherited
Nick Coghlan <ncoghlan@gmail.com>
parents: 47201
diff changeset
87
f4e7ef4329a9 Manual forward port of 64962 - use PyObject_HashNotImplemented as a tp_hash level indicator that the default hash implementation has not been inherited
Nick Coghlan <ncoghlan@gmail.com>
parents: 47201
diff changeset
88 def test_fixed_hash(self):
f4e7ef4329a9 Manual forward port of 64962 - use PyObject_HashNotImplemented as a tp_hash level indicator that the default hash implementation has not been inherited
Nick Coghlan <ncoghlan@gmail.com>
parents: 47201
diff changeset
89 for obj in self.fixed_expected:
f4e7ef4329a9 Manual forward port of 64962 - use PyObject_HashNotImplemented as a tp_hash level indicator that the default hash implementation has not been inherited
Nick Coghlan <ncoghlan@gmail.com>
parents: 47201
diff changeset
90 self.assertEqual(hash(obj), _FIXED_HASH_VALUE)
f4e7ef4329a9 Manual forward port of 64962 - use PyObject_HashNotImplemented as a tp_hash level indicator that the default hash implementation has not been inherited
Nick Coghlan <ncoghlan@gmail.com>
parents: 47201
diff changeset
91
f4e7ef4329a9 Manual forward port of 64962 - use PyObject_HashNotImplemented as a tp_hash level indicator that the default hash implementation has not been inherited
Nick Coghlan <ncoghlan@gmail.com>
parents: 47201
diff changeset
92 def test_error_hash(self):
f4e7ef4329a9 Manual forward port of 64962 - use PyObject_HashNotImplemented as a tp_hash level indicator that the default hash implementation has not been inherited
Nick Coghlan <ncoghlan@gmail.com>
parents: 47201
diff changeset
93 for obj in self.error_expected:
f4e7ef4329a9 Manual forward port of 64962 - use PyObject_HashNotImplemented as a tp_hash level indicator that the default hash implementation has not been inherited
Nick Coghlan <ncoghlan@gmail.com>
parents: 47201
diff changeset
94 self.assertRaises(TypeError, hash, obj)
f4e7ef4329a9 Manual forward port of 64962 - use PyObject_HashNotImplemented as a tp_hash level indicator that the default hash implementation has not been inherited
Nick Coghlan <ncoghlan@gmail.com>
parents: 47201
diff changeset
95
f4e7ef4329a9 Manual forward port of 64962 - use PyObject_HashNotImplemented as a tp_hash level indicator that the default hash implementation has not been inherited
Nick Coghlan <ncoghlan@gmail.com>
parents: 47201
diff changeset
96 def test_hashable(self):
f4e7ef4329a9 Manual forward port of 64962 - use PyObject_HashNotImplemented as a tp_hash level indicator that the default hash implementation has not been inherited
Nick Coghlan <ncoghlan@gmail.com>
parents: 47201
diff changeset
97 objects = (self.default_expected +
f4e7ef4329a9 Manual forward port of 64962 - use PyObject_HashNotImplemented as a tp_hash level indicator that the default hash implementation has not been inherited
Nick Coghlan <ncoghlan@gmail.com>
parents: 47201
diff changeset
98 self.fixed_expected)
f4e7ef4329a9 Manual forward port of 64962 - use PyObject_HashNotImplemented as a tp_hash level indicator that the default hash implementation has not been inherited
Nick Coghlan <ncoghlan@gmail.com>
parents: 47201
diff changeset
99 for obj in objects:
58473
71acd4482e65 Merged revisions 77727 via svnmerge from
Ezio Melotti <ezio.melotti@gmail.com>
parents: 55593
diff changeset
100 self.assertIsInstance(obj, Hashable)
48475
f4e7ef4329a9 Manual forward port of 64962 - use PyObject_HashNotImplemented as a tp_hash level indicator that the default hash implementation has not been inherited
Nick Coghlan <ncoghlan@gmail.com>
parents: 47201
diff changeset
101
f4e7ef4329a9 Manual forward port of 64962 - use PyObject_HashNotImplemented as a tp_hash level indicator that the default hash implementation has not been inherited
Nick Coghlan <ncoghlan@gmail.com>
parents: 47201
diff changeset
102 def test_not_hashable(self):
f4e7ef4329a9 Manual forward port of 64962 - use PyObject_HashNotImplemented as a tp_hash level indicator that the default hash implementation has not been inherited
Nick Coghlan <ncoghlan@gmail.com>
parents: 47201
diff changeset
103 for obj in self.error_expected:
58473
71acd4482e65 Merged revisions 77727 via svnmerge from
Ezio Melotti <ezio.melotti@gmail.com>
parents: 55593
diff changeset
104 self.assertNotIsInstance(obj, Hashable)
48475
f4e7ef4329a9 Manual forward port of 64962 - use PyObject_HashNotImplemented as a tp_hash level indicator that the default hash implementation has not been inherited
Nick Coghlan <ncoghlan@gmail.com>
parents: 47201
diff changeset
105
f4e7ef4329a9 Manual forward port of 64962 - use PyObject_HashNotImplemented as a tp_hash level indicator that the default hash implementation has not been inherited
Nick Coghlan <ncoghlan@gmail.com>
parents: 47201
diff changeset
106
50374
43aacbe647cb Recorded merge of revisions 68058 via svnmerge from
Nick Coghlan <ncoghlan@gmail.com>
parents: 49518
diff changeset
107 # Issue #4701: Check that some builtin types are correctly hashable
43aacbe647cb Recorded merge of revisions 68058 via svnmerge from
Nick Coghlan <ncoghlan@gmail.com>
parents: 49518
diff changeset
108 class DefaultIterSeq(object):
43aacbe647cb Recorded merge of revisions 68058 via svnmerge from
Nick Coghlan <ncoghlan@gmail.com>
parents: 49518
diff changeset
109 seq = range(10)
43aacbe647cb Recorded merge of revisions 68058 via svnmerge from
Nick Coghlan <ncoghlan@gmail.com>
parents: 49518
diff changeset
110 def __len__(self):
43aacbe647cb Recorded merge of revisions 68058 via svnmerge from
Nick Coghlan <ncoghlan@gmail.com>
parents: 49518
diff changeset
111 return len(self.seq)
43aacbe647cb Recorded merge of revisions 68058 via svnmerge from
Nick Coghlan <ncoghlan@gmail.com>
parents: 49518
diff changeset
112 def __getitem__(self, index):
43aacbe647cb Recorded merge of revisions 68058 via svnmerge from
Nick Coghlan <ncoghlan@gmail.com>
parents: 49518
diff changeset
113 return self.seq[index]
43aacbe647cb Recorded merge of revisions 68058 via svnmerge from
Nick Coghlan <ncoghlan@gmail.com>
parents: 49518
diff changeset
114
43aacbe647cb Recorded merge of revisions 68058 via svnmerge from
Nick Coghlan <ncoghlan@gmail.com>
parents: 49518
diff changeset
115 class HashBuiltinsTestCase(unittest.TestCase):
43aacbe647cb Recorded merge of revisions 68058 via svnmerge from
Nick Coghlan <ncoghlan@gmail.com>
parents: 49518
diff changeset
116 hashes_to_check = [range(10),
43aacbe647cb Recorded merge of revisions 68058 via svnmerge from
Nick Coghlan <ncoghlan@gmail.com>
parents: 49518
diff changeset
117 enumerate(range(10)),
43aacbe647cb Recorded merge of revisions 68058 via svnmerge from
Nick Coghlan <ncoghlan@gmail.com>
parents: 49518
diff changeset
118 iter(DefaultIterSeq()),
43aacbe647cb Recorded merge of revisions 68058 via svnmerge from
Nick Coghlan <ncoghlan@gmail.com>
parents: 49518
diff changeset
119 iter(lambda: 0, 0),
43aacbe647cb Recorded merge of revisions 68058 via svnmerge from
Nick Coghlan <ncoghlan@gmail.com>
parents: 49518
diff changeset
120 ]
43aacbe647cb Recorded merge of revisions 68058 via svnmerge from
Nick Coghlan <ncoghlan@gmail.com>
parents: 49518
diff changeset
121
43aacbe647cb Recorded merge of revisions 68058 via svnmerge from
Nick Coghlan <ncoghlan@gmail.com>
parents: 49518
diff changeset
122 def test_hashes(self):
43aacbe647cb Recorded merge of revisions 68058 via svnmerge from
Nick Coghlan <ncoghlan@gmail.com>
parents: 49518
diff changeset
123 _default_hash = object.__hash__
43aacbe647cb Recorded merge of revisions 68058 via svnmerge from
Nick Coghlan <ncoghlan@gmail.com>
parents: 49518
diff changeset
124 for obj in self.hashes_to_check:
43aacbe647cb Recorded merge of revisions 68058 via svnmerge from
Nick Coghlan <ncoghlan@gmail.com>
parents: 49518
diff changeset
125 self.assertEqual(hash(obj), _default_hash(obj))
43aacbe647cb Recorded merge of revisions 68058 via svnmerge from
Nick Coghlan <ncoghlan@gmail.com>
parents: 49518
diff changeset
126
75066
f4b7ecf8a5f8 Issue #13703: add a way to randomize the hash values of basic types (str, bytes, datetime)
Georg Brandl <georg@python.org>
parents: 55593
diff changeset
127 class HashRandomizationTests(unittest.TestCase):
f4b7ecf8a5f8 Issue #13703: add a way to randomize the hash values of basic types (str, bytes, datetime)
Georg Brandl <georg@python.org>
parents: 55593
diff changeset
128
f4b7ecf8a5f8 Issue #13703: add a way to randomize the hash values of basic types (str, bytes, datetime)
Georg Brandl <georg@python.org>
parents: 55593
diff changeset
129 # Each subclass should define a field "repr_", containing the repr() of
f4b7ecf8a5f8 Issue #13703: add a way to randomize the hash values of basic types (str, bytes, datetime)
Georg Brandl <georg@python.org>
parents: 55593
diff changeset
130 # an object to be tested
f4b7ecf8a5f8 Issue #13703: add a way to randomize the hash values of basic types (str, bytes, datetime)
Georg Brandl <georg@python.org>
parents: 55593
diff changeset
131
f4b7ecf8a5f8 Issue #13703: add a way to randomize the hash values of basic types (str, bytes, datetime)
Georg Brandl <georg@python.org>
parents: 55593
diff changeset
132 def get_hash_command(self, repr_):
f4b7ecf8a5f8 Issue #13703: add a way to randomize the hash values of basic types (str, bytes, datetime)
Georg Brandl <georg@python.org>
parents: 55593
diff changeset
133 return 'print(hash(%s))' % repr_
f4b7ecf8a5f8 Issue #13703: add a way to randomize the hash values of basic types (str, bytes, datetime)
Georg Brandl <georg@python.org>
parents: 55593
diff changeset
134
f4b7ecf8a5f8 Issue #13703: add a way to randomize the hash values of basic types (str, bytes, datetime)
Georg Brandl <georg@python.org>
parents: 55593
diff changeset
135 def get_hash(self, repr_, seed=None):
f4b7ecf8a5f8 Issue #13703: add a way to randomize the hash values of basic types (str, bytes, datetime)
Georg Brandl <georg@python.org>
parents: 55593
diff changeset
136 env = os.environ.copy()
f4b7ecf8a5f8 Issue #13703: add a way to randomize the hash values of basic types (str, bytes, datetime)
Georg Brandl <georg@python.org>
parents: 55593
diff changeset
137 env['__cleanenv'] = True # signal to assert_python not to do a copy
f4b7ecf8a5f8 Issue #13703: add a way to randomize the hash values of basic types (str, bytes, datetime)
Georg Brandl <georg@python.org>
parents: 55593
diff changeset
138 # of os.environ on its own
f4b7ecf8a5f8 Issue #13703: add a way to randomize the hash values of basic types (str, bytes, datetime)
Georg Brandl <georg@python.org>
parents: 55593
diff changeset
139 if seed is not None:
f4b7ecf8a5f8 Issue #13703: add a way to randomize the hash values of basic types (str, bytes, datetime)
Georg Brandl <georg@python.org>
parents: 55593
diff changeset
140 env['PYTHONHASHSEED'] = str(seed)
f4b7ecf8a5f8 Issue #13703: add a way to randomize the hash values of basic types (str, bytes, datetime)
Georg Brandl <georg@python.org>
parents: 55593
diff changeset
141 else:
f4b7ecf8a5f8 Issue #13703: add a way to randomize the hash values of basic types (str, bytes, datetime)
Georg Brandl <georg@python.org>
parents: 55593
diff changeset
142 env.pop('PYTHONHASHSEED', None)
f4b7ecf8a5f8 Issue #13703: add a way to randomize the hash values of basic types (str, bytes, datetime)
Georg Brandl <georg@python.org>
parents: 55593
diff changeset
143 out = assert_python_ok(
f4b7ecf8a5f8 Issue #13703: add a way to randomize the hash values of basic types (str, bytes, datetime)
Georg Brandl <georg@python.org>
parents: 55593
diff changeset
144 '-c', self.get_hash_command(repr_),
f4b7ecf8a5f8 Issue #13703: add a way to randomize the hash values of basic types (str, bytes, datetime)
Georg Brandl <georg@python.org>
parents: 55593
diff changeset
145 **env)
f4b7ecf8a5f8 Issue #13703: add a way to randomize the hash values of basic types (str, bytes, datetime)
Georg Brandl <georg@python.org>
parents: 55593
diff changeset
146 stdout = out[1].strip()
f4b7ecf8a5f8 Issue #13703: add a way to randomize the hash values of basic types (str, bytes, datetime)
Georg Brandl <georg@python.org>
parents: 55593
diff changeset
147 return int(stdout)
f4b7ecf8a5f8 Issue #13703: add a way to randomize the hash values of basic types (str, bytes, datetime)
Georg Brandl <georg@python.org>
parents: 55593
diff changeset
148
f4b7ecf8a5f8 Issue #13703: add a way to randomize the hash values of basic types (str, bytes, datetime)
Georg Brandl <georg@python.org>
parents: 55593
diff changeset
149 def test_randomized_hash(self):
f4b7ecf8a5f8 Issue #13703: add a way to randomize the hash values of basic types (str, bytes, datetime)
Georg Brandl <georg@python.org>
parents: 55593
diff changeset
150 # two runs should return different hashes
f4b7ecf8a5f8 Issue #13703: add a way to randomize the hash values of basic types (str, bytes, datetime)
Georg Brandl <georg@python.org>
parents: 55593
diff changeset
151 run1 = self.get_hash(self.repr_, seed='random')
f4b7ecf8a5f8 Issue #13703: add a way to randomize the hash values of basic types (str, bytes, datetime)
Georg Brandl <georg@python.org>
parents: 55593
diff changeset
152 run2 = self.get_hash(self.repr_, seed='random')
f4b7ecf8a5f8 Issue #13703: add a way to randomize the hash values of basic types (str, bytes, datetime)
Georg Brandl <georg@python.org>
parents: 55593
diff changeset
153 self.assertNotEqual(run1, run2)
f4b7ecf8a5f8 Issue #13703: add a way to randomize the hash values of basic types (str, bytes, datetime)
Georg Brandl <georg@python.org>
parents: 55593
diff changeset
154
f4b7ecf8a5f8 Issue #13703: add a way to randomize the hash values of basic types (str, bytes, datetime)
Georg Brandl <georg@python.org>
parents: 55593
diff changeset
155 class StringlikeHashRandomizationTests(HashRandomizationTests):
f4b7ecf8a5f8 Issue #13703: add a way to randomize the hash values of basic types (str, bytes, datetime)
Georg Brandl <georg@python.org>
parents: 55593
diff changeset
156 def test_null_hash(self):
f4b7ecf8a5f8 Issue #13703: add a way to randomize the hash values of basic types (str, bytes, datetime)
Georg Brandl <georg@python.org>
parents: 55593
diff changeset
157 # PYTHONHASHSEED=0 disables the randomized hash
f4b7ecf8a5f8 Issue #13703: add a way to randomize the hash values of basic types (str, bytes, datetime)
Georg Brandl <georg@python.org>
parents: 55593
diff changeset
158 if IS_64BIT:
f4b7ecf8a5f8 Issue #13703: add a way to randomize the hash values of basic types (str, bytes, datetime)
Georg Brandl <georg@python.org>
parents: 55593
diff changeset
159 known_hash_of_obj = 1453079729188098211
f4b7ecf8a5f8 Issue #13703: add a way to randomize the hash values of basic types (str, bytes, datetime)
Georg Brandl <georg@python.org>
parents: 55593
diff changeset
160 else:
f4b7ecf8a5f8 Issue #13703: add a way to randomize the hash values of basic types (str, bytes, datetime)
Georg Brandl <georg@python.org>
parents: 55593
diff changeset
161 known_hash_of_obj = -1600925533
f4b7ecf8a5f8 Issue #13703: add a way to randomize the hash values of basic types (str, bytes, datetime)
Georg Brandl <georg@python.org>
parents: 55593
diff changeset
162
f4b7ecf8a5f8 Issue #13703: add a way to randomize the hash values of basic types (str, bytes, datetime)
Georg Brandl <georg@python.org>
parents: 55593
diff changeset
163 # Randomization is disabled by default:
f4b7ecf8a5f8 Issue #13703: add a way to randomize the hash values of basic types (str, bytes, datetime)
Georg Brandl <georg@python.org>
parents: 55593
diff changeset
164 self.assertEqual(self.get_hash(self.repr_), known_hash_of_obj)
f4b7ecf8a5f8 Issue #13703: add a way to randomize the hash values of basic types (str, bytes, datetime)
Georg Brandl <georg@python.org>
parents: 55593
diff changeset
165
f4b7ecf8a5f8 Issue #13703: add a way to randomize the hash values of basic types (str, bytes, datetime)
Georg Brandl <georg@python.org>
parents: 55593
diff changeset
166 # It can also be disabled by setting the seed to 0:
f4b7ecf8a5f8 Issue #13703: add a way to randomize the hash values of basic types (str, bytes, datetime)
Georg Brandl <georg@python.org>
parents: 55593
diff changeset
167 self.assertEqual(self.get_hash(self.repr_, seed=0), known_hash_of_obj)
f4b7ecf8a5f8 Issue #13703: add a way to randomize the hash values of basic types (str, bytes, datetime)
Georg Brandl <georg@python.org>
parents: 55593
diff changeset
168
f4b7ecf8a5f8 Issue #13703: add a way to randomize the hash values of basic types (str, bytes, datetime)
Georg Brandl <georg@python.org>
parents: 55593
diff changeset
169 def test_fixed_hash(self):
f4b7ecf8a5f8 Issue #13703: add a way to randomize the hash values of basic types (str, bytes, datetime)
Georg Brandl <georg@python.org>
parents: 55593
diff changeset
170 # test a fixed seed for the randomized hash
f4b7ecf8a5f8 Issue #13703: add a way to randomize the hash values of basic types (str, bytes, datetime)
Georg Brandl <georg@python.org>
parents: 55593
diff changeset
171 # Note that all types share the same values:
f4b7ecf8a5f8 Issue #13703: add a way to randomize the hash values of basic types (str, bytes, datetime)
Georg Brandl <georg@python.org>
parents: 55593
diff changeset
172 if IS_64BIT:
75178
eb46c8f44aae Fix (presumably) test_hash under big-endian systems (PPC).
Antoine Pitrou <solipsis@pitrou.net>
parents: 75073
diff changeset
173 if sys.byteorder == 'little':
eb46c8f44aae Fix (presumably) test_hash under big-endian systems (PPC).
Antoine Pitrou <solipsis@pitrou.net>
parents: 75073
diff changeset
174 h = -4410911502303878509
eb46c8f44aae Fix (presumably) test_hash under big-endian systems (PPC).
Antoine Pitrou <solipsis@pitrou.net>
parents: 75073
diff changeset
175 else:
eb46c8f44aae Fix (presumably) test_hash under big-endian systems (PPC).
Antoine Pitrou <solipsis@pitrou.net>
parents: 75073
diff changeset
176 h = -3570150969479994130
75066
f4b7ecf8a5f8 Issue #13703: add a way to randomize the hash values of basic types (str, bytes, datetime)
Georg Brandl <georg@python.org>
parents: 55593
diff changeset
177 else:
75178
eb46c8f44aae Fix (presumably) test_hash under big-endian systems (PPC).
Antoine Pitrou <solipsis@pitrou.net>
parents: 75073
diff changeset
178 if sys.byteorder == 'little':
eb46c8f44aae Fix (presumably) test_hash under big-endian systems (PPC).
Antoine Pitrou <solipsis@pitrou.net>
parents: 75073
diff changeset
179 h = -206076799
eb46c8f44aae Fix (presumably) test_hash under big-endian systems (PPC).
Antoine Pitrou <solipsis@pitrou.net>
parents: 75073
diff changeset
180 else:
eb46c8f44aae Fix (presumably) test_hash under big-endian systems (PPC).
Antoine Pitrou <solipsis@pitrou.net>
parents: 75073
diff changeset
181 h = -1024014457
75066
f4b7ecf8a5f8 Issue #13703: add a way to randomize the hash values of basic types (str, bytes, datetime)
Georg Brandl <georg@python.org>
parents: 55593
diff changeset
182 self.assertEqual(self.get_hash(self.repr_, seed=42), h)
f4b7ecf8a5f8 Issue #13703: add a way to randomize the hash values of basic types (str, bytes, datetime)
Georg Brandl <georg@python.org>
parents: 55593
diff changeset
183
f4b7ecf8a5f8 Issue #13703: add a way to randomize the hash values of basic types (str, bytes, datetime)
Georg Brandl <georg@python.org>
parents: 55593
diff changeset
184 class StrHashRandomizationTests(StringlikeHashRandomizationTests):
f4b7ecf8a5f8 Issue #13703: add a way to randomize the hash values of basic types (str, bytes, datetime)
Georg Brandl <georg@python.org>
parents: 55593
diff changeset
185 repr_ = repr('abc')
f4b7ecf8a5f8 Issue #13703: add a way to randomize the hash values of basic types (str, bytes, datetime)
Georg Brandl <georg@python.org>
parents: 55593
diff changeset
186
f4b7ecf8a5f8 Issue #13703: add a way to randomize the hash values of basic types (str, bytes, datetime)
Georg Brandl <georg@python.org>
parents: 55593
diff changeset
187 def test_empty_string(self):
f4b7ecf8a5f8 Issue #13703: add a way to randomize the hash values of basic types (str, bytes, datetime)
Georg Brandl <georg@python.org>
parents: 55593
diff changeset
188 self.assertEqual(hash(""), 0)
f4b7ecf8a5f8 Issue #13703: add a way to randomize the hash values of basic types (str, bytes, datetime)
Georg Brandl <georg@python.org>
parents: 55593
diff changeset
189
f4b7ecf8a5f8 Issue #13703: add a way to randomize the hash values of basic types (str, bytes, datetime)
Georg Brandl <georg@python.org>
parents: 55593
diff changeset
190 class BytesHashRandomizationTests(StringlikeHashRandomizationTests):
f4b7ecf8a5f8 Issue #13703: add a way to randomize the hash values of basic types (str, bytes, datetime)
Georg Brandl <georg@python.org>
parents: 55593
diff changeset
191 repr_ = repr(b'abc')
f4b7ecf8a5f8 Issue #13703: add a way to randomize the hash values of basic types (str, bytes, datetime)
Georg Brandl <georg@python.org>
parents: 55593
diff changeset
192
f4b7ecf8a5f8 Issue #13703: add a way to randomize the hash values of basic types (str, bytes, datetime)
Georg Brandl <georg@python.org>
parents: 55593
diff changeset
193 def test_empty_string(self):
f4b7ecf8a5f8 Issue #13703: add a way to randomize the hash values of basic types (str, bytes, datetime)
Georg Brandl <georg@python.org>
parents: 55593
diff changeset
194 self.assertEqual(hash(b""), 0)
f4b7ecf8a5f8 Issue #13703: add a way to randomize the hash values of basic types (str, bytes, datetime)
Georg Brandl <georg@python.org>
parents: 55593
diff changeset
195
f4b7ecf8a5f8 Issue #13703: add a way to randomize the hash values of basic types (str, bytes, datetime)
Georg Brandl <georg@python.org>
parents: 55593
diff changeset
196 class DatetimeTests(HashRandomizationTests):
f4b7ecf8a5f8 Issue #13703: add a way to randomize the hash values of basic types (str, bytes, datetime)
Georg Brandl <georg@python.org>
parents: 55593
diff changeset
197 def get_hash_command(self, repr_):
f4b7ecf8a5f8 Issue #13703: add a way to randomize the hash values of basic types (str, bytes, datetime)
Georg Brandl <georg@python.org>
parents: 55593
diff changeset
198 return 'import datetime; print(hash(%s))' % repr_
f4b7ecf8a5f8 Issue #13703: add a way to randomize the hash values of basic types (str, bytes, datetime)
Georg Brandl <georg@python.org>
parents: 55593
diff changeset
199
f4b7ecf8a5f8 Issue #13703: add a way to randomize the hash values of basic types (str, bytes, datetime)
Georg Brandl <georg@python.org>
parents: 55593
diff changeset
200 class DatetimeDateTests(DatetimeTests):
f4b7ecf8a5f8 Issue #13703: add a way to randomize the hash values of basic types (str, bytes, datetime)
Georg Brandl <georg@python.org>
parents: 55593
diff changeset
201 repr_ = repr(datetime.date(1066, 10, 14))
f4b7ecf8a5f8 Issue #13703: add a way to randomize the hash values of basic types (str, bytes, datetime)
Georg Brandl <georg@python.org>
parents: 55593
diff changeset
202
f4b7ecf8a5f8 Issue #13703: add a way to randomize the hash values of basic types (str, bytes, datetime)
Georg Brandl <georg@python.org>
parents: 55593
diff changeset
203 class DatetimeDatetimeTests(DatetimeTests):
f4b7ecf8a5f8 Issue #13703: add a way to randomize the hash values of basic types (str, bytes, datetime)
Georg Brandl <georg@python.org>
parents: 55593
diff changeset
204 repr_ = repr(datetime.datetime(1, 2, 3, 4, 5, 6, 7))
f4b7ecf8a5f8 Issue #13703: add a way to randomize the hash values of basic types (str, bytes, datetime)
Georg Brandl <georg@python.org>
parents: 55593
diff changeset
205
f4b7ecf8a5f8 Issue #13703: add a way to randomize the hash values of basic types (str, bytes, datetime)
Georg Brandl <georg@python.org>
parents: 55593
diff changeset
206 class DatetimeTimeTests(DatetimeTests):
f4b7ecf8a5f8 Issue #13703: add a way to randomize the hash values of basic types (str, bytes, datetime)
Georg Brandl <georg@python.org>
parents: 55593
diff changeset
207 repr_ = repr(datetime.time(0))
f4b7ecf8a5f8 Issue #13703: add a way to randomize the hash values of basic types (str, bytes, datetime)
Georg Brandl <georg@python.org>
parents: 55593
diff changeset
208
f4b7ecf8a5f8 Issue #13703: add a way to randomize the hash values of basic types (str, bytes, datetime)
Georg Brandl <georg@python.org>
parents: 55593
diff changeset
209
20013
e3184e46303b Change the PyUnit-based tests to use the test_main() approach. This
Fred Drake <fdrake@acm.org>
parents: 17860
diff changeset
210 def test_main():
48475
f4e7ef4329a9 Manual forward port of 64962 - use PyObject_HashNotImplemented as a tp_hash level indicator that the default hash implementation has not been inherited
Nick Coghlan <ncoghlan@gmail.com>
parents: 47201
diff changeset
211 support.run_unittest(HashEqualityTestCase,
75066
f4b7ecf8a5f8 Issue #13703: add a way to randomize the hash values of basic types (str, bytes, datetime)
Georg Brandl <georg@python.org>
parents: 55593
diff changeset
212 HashInheritanceTestCase,
f4b7ecf8a5f8 Issue #13703: add a way to randomize the hash values of basic types (str, bytes, datetime)
Georg Brandl <georg@python.org>
parents: 55593
diff changeset
213 HashBuiltinsTestCase,
f4b7ecf8a5f8 Issue #13703: add a way to randomize the hash values of basic types (str, bytes, datetime)
Georg Brandl <georg@python.org>
parents: 55593
diff changeset
214 StrHashRandomizationTests,
f4b7ecf8a5f8 Issue #13703: add a way to randomize the hash values of basic types (str, bytes, datetime)
Georg Brandl <georg@python.org>
parents: 55593
diff changeset
215 BytesHashRandomizationTests,
f4b7ecf8a5f8 Issue #13703: add a way to randomize the hash values of basic types (str, bytes, datetime)
Georg Brandl <georg@python.org>
parents: 55593
diff changeset
216 DatetimeDateTests,
f4b7ecf8a5f8 Issue #13703: add a way to randomize the hash values of basic types (str, bytes, datetime)
Georg Brandl <georg@python.org>
parents: 55593
diff changeset
217 DatetimeDatetimeTests,
f4b7ecf8a5f8 Issue #13703: add a way to randomize the hash values of basic types (str, bytes, datetime)
Georg Brandl <georg@python.org>
parents: 55593
diff changeset
218 DatetimeTimeTests)
20013
e3184e46303b Change the PyUnit-based tests to use the test_main() approach. This
Fred Drake <fdrake@acm.org>
parents: 17860
diff changeset
219
e3184e46303b Change the PyUnit-based tests to use the test_main() approach. This
Fred Drake <fdrake@acm.org>
parents: 17860
diff changeset
220
e3184e46303b Change the PyUnit-based tests to use the test_main() approach. This
Fred Drake <fdrake@acm.org>
parents: 17860
diff changeset
221 if __name__ == "__main__":
e3184e46303b Change the PyUnit-based tests to use the test_main() approach. This
Fred Drake <fdrake@acm.org>
parents: 17860
diff changeset
222 test_main()