Mercurial > cpython-lru_cache-weakref
annotate Lib/test/test_class.py @ 87690:66c1c9f32567 default tip
Add use_weakref option to functools.lru_cache
The use_weakref option makes lru_cache create weak references to the function
arguments when creating the cache key, which prevents them from staying in the
memory forever even after all other references to them are gone.
This is a proof of concept for http://bugs.python.org/issue19859
| author | Radomir Dopieralski <devel@sheep.art.pl> |
|---|---|
| date | Tue, 03 Dec 2013 16:02:48 +0100 |
| parents | 9fe76c26ea9f |
| children |
| rev | line source |
|---|---|
|
14037
91f847a783d2
Apply SF patch #101029: call __getitem__ with a proper slice object if there
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
1 "Test the functionality of Python classes implementing operators." |
|
91f847a783d2
Apply SF patch #101029: call __getitem__ with a proper slice object if there
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
2 |
|
42954
27f0289b6835
Merge the trunk changes in. Breaks socket.ssl for now.
Thomas Wouters <thomas@python.org>
parents:
42084
diff
changeset
|
3 import unittest |
|
27f0289b6835
Merge the trunk changes in. Breaks socket.ssl for now.
Thomas Wouters <thomas@python.org>
parents:
42084
diff
changeset
|
4 |
|
47201
9c930a32cebb
#2621 rename test.test_support to test.support
Benjamin Peterson <benjamin@python.org>
parents:
45471
diff
changeset
|
5 from test import support |
|
14037
91f847a783d2
Apply SF patch #101029: call __getitem__ with a proper slice object if there
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
6 |
|
91f847a783d2
Apply SF patch #101029: call __getitem__ with a proper slice object if there
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
7 testmeths = [ |
|
91f847a783d2
Apply SF patch #101029: call __getitem__ with a proper slice object if there
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
8 |
|
91f847a783d2
Apply SF patch #101029: call __getitem__ with a proper slice object if there
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
9 # Binary operations |
|
91f847a783d2
Apply SF patch #101029: call __getitem__ with a proper slice object if there
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
10 "add", |
|
91f847a783d2
Apply SF patch #101029: call __getitem__ with a proper slice object if there
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
11 "radd", |
|
91f847a783d2
Apply SF patch #101029: call __getitem__ with a proper slice object if there
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
12 "sub", |
|
91f847a783d2
Apply SF patch #101029: call __getitem__ with a proper slice object if there
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
13 "rsub", |
|
91f847a783d2
Apply SF patch #101029: call __getitem__ with a proper slice object if there
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
14 "mul", |
|
91f847a783d2
Apply SF patch #101029: call __getitem__ with a proper slice object if there
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
15 "rmul", |
|
37191
4bfe8afe8f65
Get rid of remnants of integer division
Neal Norwitz <nnorwitz@gmail.com>
parents:
35096
diff
changeset
|
16 "truediv", |
|
4bfe8afe8f65
Get rid of remnants of integer division
Neal Norwitz <nnorwitz@gmail.com>
parents:
35096
diff
changeset
|
17 "rtruediv", |
|
14037
91f847a783d2
Apply SF patch #101029: call __getitem__ with a proper slice object if there
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
18 "mod", |
|
91f847a783d2
Apply SF patch #101029: call __getitem__ with a proper slice object if there
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
19 "rmod", |
|
91f847a783d2
Apply SF patch #101029: call __getitem__ with a proper slice object if there
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
20 "divmod", |
|
91f847a783d2
Apply SF patch #101029: call __getitem__ with a proper slice object if there
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
21 "rdivmod", |
|
91f847a783d2
Apply SF patch #101029: call __getitem__ with a proper slice object if there
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
22 "pow", |
|
91f847a783d2
Apply SF patch #101029: call __getitem__ with a proper slice object if there
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
23 "rpow", |
|
91f847a783d2
Apply SF patch #101029: call __getitem__ with a proper slice object if there
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
24 "rshift", |
|
91f847a783d2
Apply SF patch #101029: call __getitem__ with a proper slice object if there
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
25 "rrshift", |
|
91f847a783d2
Apply SF patch #101029: call __getitem__ with a proper slice object if there
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
26 "lshift", |
|
91f847a783d2
Apply SF patch #101029: call __getitem__ with a proper slice object if there
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
27 "rlshift", |
|
91f847a783d2
Apply SF patch #101029: call __getitem__ with a proper slice object if there
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
28 "and", |
|
91f847a783d2
Apply SF patch #101029: call __getitem__ with a proper slice object if there
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
29 "rand", |
|
91f847a783d2
Apply SF patch #101029: call __getitem__ with a proper slice object if there
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
30 "or", |
|
91f847a783d2
Apply SF patch #101029: call __getitem__ with a proper slice object if there
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
31 "ror", |
|
91f847a783d2
Apply SF patch #101029: call __getitem__ with a proper slice object if there
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
32 "xor", |
|
91f847a783d2
Apply SF patch #101029: call __getitem__ with a proper slice object if there
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
33 "rxor", |
|
91f847a783d2
Apply SF patch #101029: call __getitem__ with a proper slice object if there
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
34 |
|
91f847a783d2
Apply SF patch #101029: call __getitem__ with a proper slice object if there
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
35 # List/dict operations |
|
91f847a783d2
Apply SF patch #101029: call __getitem__ with a proper slice object if there
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
36 "contains", |
|
91f847a783d2
Apply SF patch #101029: call __getitem__ with a proper slice object if there
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
37 "getitem", |
|
91f847a783d2
Apply SF patch #101029: call __getitem__ with a proper slice object if there
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
38 "setitem", |
|
91f847a783d2
Apply SF patch #101029: call __getitem__ with a proper slice object if there
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
39 "delitem", |
|
91f847a783d2
Apply SF patch #101029: call __getitem__ with a proper slice object if there
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
40 |
|
91f847a783d2
Apply SF patch #101029: call __getitem__ with a proper slice object if there
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
41 # Unary operations |
|
91f847a783d2
Apply SF patch #101029: call __getitem__ with a proper slice object if there
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
42 "neg", |
|
91f847a783d2
Apply SF patch #101029: call __getitem__ with a proper slice object if there
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
43 "pos", |
|
91f847a783d2
Apply SF patch #101029: call __getitem__ with a proper slice object if there
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
44 "abs", |
|
91f847a783d2
Apply SF patch #101029: call __getitem__ with a proper slice object if there
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
45 |
|
91f847a783d2
Apply SF patch #101029: call __getitem__ with a proper slice object if there
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
46 # generic operations |
|
91f847a783d2
Apply SF patch #101029: call __getitem__ with a proper slice object if there
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
47 "init", |
|
91f847a783d2
Apply SF patch #101029: call __getitem__ with a proper slice object if there
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
48 ] |
|
91f847a783d2
Apply SF patch #101029: call __getitem__ with a proper slice object if there
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
49 |
|
91f847a783d2
Apply SF patch #101029: call __getitem__ with a proper slice object if there
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
50 # These need to return something other than None |
|
91f847a783d2
Apply SF patch #101029: call __getitem__ with a proper slice object if there
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
51 # "hash", |
|
91f847a783d2
Apply SF patch #101029: call __getitem__ with a proper slice object if there
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
52 # "str", |
|
91f847a783d2
Apply SF patch #101029: call __getitem__ with a proper slice object if there
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
53 # "repr", |
|
32759
d1777f51923b
Check the type of values returned by __int__, __float__, __long__,
Neil Schemenauer <nascheme@enme.ucalgary.ca>
parents:
30723
diff
changeset
|
54 # "int", |
|
d1777f51923b
Check the type of values returned by __int__, __float__, __long__,
Neil Schemenauer <nascheme@enme.ucalgary.ca>
parents:
30723
diff
changeset
|
55 # "float", |
|
14037
91f847a783d2
Apply SF patch #101029: call __getitem__ with a proper slice object if there
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
56 |
|
91f847a783d2
Apply SF patch #101029: call __getitem__ with a proper slice object if there
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
57 # These are separate because they can influence the test of other methods. |
|
91f847a783d2
Apply SF patch #101029: call __getitem__ with a proper slice object if there
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
58 # "getattr", |
|
91f847a783d2
Apply SF patch #101029: call __getitem__ with a proper slice object if there
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
59 # "setattr", |
|
91f847a783d2
Apply SF patch #101029: call __getitem__ with a proper slice object if there
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
60 # "delattr", |
|
91f847a783d2
Apply SF patch #101029: call __getitem__ with a proper slice object if there
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
61 |
|
42954
27f0289b6835
Merge the trunk changes in. Breaks socket.ssl for now.
Thomas Wouters <thomas@python.org>
parents:
42084
diff
changeset
|
62 callLst = [] |
|
27f0289b6835
Merge the trunk changes in. Breaks socket.ssl for now.
Thomas Wouters <thomas@python.org>
parents:
42084
diff
changeset
|
63 def trackCall(f): |
|
27f0289b6835
Merge the trunk changes in. Breaks socket.ssl for now.
Thomas Wouters <thomas@python.org>
parents:
42084
diff
changeset
|
64 def track(*args, **kwargs): |
|
27f0289b6835
Merge the trunk changes in. Breaks socket.ssl for now.
Thomas Wouters <thomas@python.org>
parents:
42084
diff
changeset
|
65 callLst.append((f.__name__, args)) |
|
27f0289b6835
Merge the trunk changes in. Breaks socket.ssl for now.
Thomas Wouters <thomas@python.org>
parents:
42084
diff
changeset
|
66 return f(*args, **kwargs) |
|
27f0289b6835
Merge the trunk changes in. Breaks socket.ssl for now.
Thomas Wouters <thomas@python.org>
parents:
42084
diff
changeset
|
67 return track |
|
14037
91f847a783d2
Apply SF patch #101029: call __getitem__ with a proper slice object if there
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
68 |
|
42954
27f0289b6835
Merge the trunk changes in. Breaks socket.ssl for now.
Thomas Wouters <thomas@python.org>
parents:
42084
diff
changeset
|
69 statictests = """ |
|
27f0289b6835
Merge the trunk changes in. Breaks socket.ssl for now.
Thomas Wouters <thomas@python.org>
parents:
42084
diff
changeset
|
70 @trackCall |
|
27f0289b6835
Merge the trunk changes in. Breaks socket.ssl for now.
Thomas Wouters <thomas@python.org>
parents:
42084
diff
changeset
|
71 def __hash__(self, *args): |
|
27f0289b6835
Merge the trunk changes in. Breaks socket.ssl for now.
Thomas Wouters <thomas@python.org>
parents:
42084
diff
changeset
|
72 return hash(id(self)) |
|
14037
91f847a783d2
Apply SF patch #101029: call __getitem__ with a proper slice object if there
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
73 |
|
42954
27f0289b6835
Merge the trunk changes in. Breaks socket.ssl for now.
Thomas Wouters <thomas@python.org>
parents:
42084
diff
changeset
|
74 @trackCall |
|
27f0289b6835
Merge the trunk changes in. Breaks socket.ssl for now.
Thomas Wouters <thomas@python.org>
parents:
42084
diff
changeset
|
75 def __str__(self, *args): |
|
27f0289b6835
Merge the trunk changes in. Breaks socket.ssl for now.
Thomas Wouters <thomas@python.org>
parents:
42084
diff
changeset
|
76 return "AllTests" |
|
32759
d1777f51923b
Check the type of values returned by __int__, __float__, __long__,
Neil Schemenauer <nascheme@enme.ucalgary.ca>
parents:
30723
diff
changeset
|
77 |
|
42954
27f0289b6835
Merge the trunk changes in. Breaks socket.ssl for now.
Thomas Wouters <thomas@python.org>
parents:
42084
diff
changeset
|
78 @trackCall |
|
27f0289b6835
Merge the trunk changes in. Breaks socket.ssl for now.
Thomas Wouters <thomas@python.org>
parents:
42084
diff
changeset
|
79 def __repr__(self, *args): |
|
27f0289b6835
Merge the trunk changes in. Breaks socket.ssl for now.
Thomas Wouters <thomas@python.org>
parents:
42084
diff
changeset
|
80 return "AllTests" |
|
42084
229c28cb9afb
Merged revisions 55817-55961 via svnmerge from
Guido van Rossum <guido@python.org>
parents:
40788
diff
changeset
|
81 |
|
42954
27f0289b6835
Merge the trunk changes in. Breaks socket.ssl for now.
Thomas Wouters <thomas@python.org>
parents:
42084
diff
changeset
|
82 @trackCall |
|
27f0289b6835
Merge the trunk changes in. Breaks socket.ssl for now.
Thomas Wouters <thomas@python.org>
parents:
42084
diff
changeset
|
83 def __int__(self, *args): |
|
27f0289b6835
Merge the trunk changes in. Breaks socket.ssl for now.
Thomas Wouters <thomas@python.org>
parents:
42084
diff
changeset
|
84 return 1 |
|
32759
d1777f51923b
Check the type of values returned by __int__, __float__, __long__,
Neil Schemenauer <nascheme@enme.ucalgary.ca>
parents:
30723
diff
changeset
|
85 |
|
42954
27f0289b6835
Merge the trunk changes in. Breaks socket.ssl for now.
Thomas Wouters <thomas@python.org>
parents:
42084
diff
changeset
|
86 @trackCall |
|
27f0289b6835
Merge the trunk changes in. Breaks socket.ssl for now.
Thomas Wouters <thomas@python.org>
parents:
42084
diff
changeset
|
87 def __index__(self, *args): |
|
27f0289b6835
Merge the trunk changes in. Breaks socket.ssl for now.
Thomas Wouters <thomas@python.org>
parents:
42084
diff
changeset
|
88 return 1 |
|
14037
91f847a783d2
Apply SF patch #101029: call __getitem__ with a proper slice object if there
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
89 |
|
42954
27f0289b6835
Merge the trunk changes in. Breaks socket.ssl for now.
Thomas Wouters <thomas@python.org>
parents:
42084
diff
changeset
|
90 @trackCall |
|
27f0289b6835
Merge the trunk changes in. Breaks socket.ssl for now.
Thomas Wouters <thomas@python.org>
parents:
42084
diff
changeset
|
91 def __float__(self, *args): |
|
27f0289b6835
Merge the trunk changes in. Breaks socket.ssl for now.
Thomas Wouters <thomas@python.org>
parents:
42084
diff
changeset
|
92 return 1.0 |
|
27f0289b6835
Merge the trunk changes in. Breaks socket.ssl for now.
Thomas Wouters <thomas@python.org>
parents:
42084
diff
changeset
|
93 |
|
27f0289b6835
Merge the trunk changes in. Breaks socket.ssl for now.
Thomas Wouters <thomas@python.org>
parents:
42084
diff
changeset
|
94 @trackCall |
|
27f0289b6835
Merge the trunk changes in. Breaks socket.ssl for now.
Thomas Wouters <thomas@python.org>
parents:
42084
diff
changeset
|
95 def __eq__(self, *args): |
|
27f0289b6835
Merge the trunk changes in. Breaks socket.ssl for now.
Thomas Wouters <thomas@python.org>
parents:
42084
diff
changeset
|
96 return True |
|
39644
13d5e5f0e993
Restructure comparison dramatically. There is no longer a default
Guido van Rossum <guido@python.org>
parents:
39222
diff
changeset
|
97 |
|
42954
27f0289b6835
Merge the trunk changes in. Breaks socket.ssl for now.
Thomas Wouters <thomas@python.org>
parents:
42084
diff
changeset
|
98 @trackCall |
|
27f0289b6835
Merge the trunk changes in. Breaks socket.ssl for now.
Thomas Wouters <thomas@python.org>
parents:
42084
diff
changeset
|
99 def __ne__(self, *args): |
|
27f0289b6835
Merge the trunk changes in. Breaks socket.ssl for now.
Thomas Wouters <thomas@python.org>
parents:
42084
diff
changeset
|
100 return False |
|
39644
13d5e5f0e993
Restructure comparison dramatically. There is no longer a default
Guido van Rossum <guido@python.org>
parents:
39222
diff
changeset
|
101 |
|
42954
27f0289b6835
Merge the trunk changes in. Breaks socket.ssl for now.
Thomas Wouters <thomas@python.org>
parents:
42084
diff
changeset
|
102 @trackCall |
|
27f0289b6835
Merge the trunk changes in. Breaks socket.ssl for now.
Thomas Wouters <thomas@python.org>
parents:
42084
diff
changeset
|
103 def __lt__(self, *args): |
|
27f0289b6835
Merge the trunk changes in. Breaks socket.ssl for now.
Thomas Wouters <thomas@python.org>
parents:
42084
diff
changeset
|
104 return False |
|
39644
13d5e5f0e993
Restructure comparison dramatically. There is no longer a default
Guido van Rossum <guido@python.org>
parents:
39222
diff
changeset
|
105 |
|
42954
27f0289b6835
Merge the trunk changes in. Breaks socket.ssl for now.
Thomas Wouters <thomas@python.org>
parents:
42084
diff
changeset
|
106 @trackCall |
|
27f0289b6835
Merge the trunk changes in. Breaks socket.ssl for now.
Thomas Wouters <thomas@python.org>
parents:
42084
diff
changeset
|
107 def __le__(self, *args): |
|
27f0289b6835
Merge the trunk changes in. Breaks socket.ssl for now.
Thomas Wouters <thomas@python.org>
parents:
42084
diff
changeset
|
108 return True |
|
39644
13d5e5f0e993
Restructure comparison dramatically. There is no longer a default
Guido van Rossum <guido@python.org>
parents:
39222
diff
changeset
|
109 |
|
42954
27f0289b6835
Merge the trunk changes in. Breaks socket.ssl for now.
Thomas Wouters <thomas@python.org>
parents:
42084
diff
changeset
|
110 @trackCall |
|
27f0289b6835
Merge the trunk changes in. Breaks socket.ssl for now.
Thomas Wouters <thomas@python.org>
parents:
42084
diff
changeset
|
111 def __gt__(self, *args): |
|
27f0289b6835
Merge the trunk changes in. Breaks socket.ssl for now.
Thomas Wouters <thomas@python.org>
parents:
42084
diff
changeset
|
112 return False |
|
39644
13d5e5f0e993
Restructure comparison dramatically. There is no longer a default
Guido van Rossum <guido@python.org>
parents:
39222
diff
changeset
|
113 |
|
42954
27f0289b6835
Merge the trunk changes in. Breaks socket.ssl for now.
Thomas Wouters <thomas@python.org>
parents:
42084
diff
changeset
|
114 @trackCall |
|
27f0289b6835
Merge the trunk changes in. Breaks socket.ssl for now.
Thomas Wouters <thomas@python.org>
parents:
42084
diff
changeset
|
115 def __ge__(self, *args): |
|
27f0289b6835
Merge the trunk changes in. Breaks socket.ssl for now.
Thomas Wouters <thomas@python.org>
parents:
42084
diff
changeset
|
116 return True |
|
27f0289b6835
Merge the trunk changes in. Breaks socket.ssl for now.
Thomas Wouters <thomas@python.org>
parents:
42084
diff
changeset
|
117 """ |
|
19406
9306f828fbb7
Committing and closing SF patch #403671 by Finn Bock to help Jython
Barry Warsaw <barry@python.org>
parents:
16104
diff
changeset
|
118 |
|
42954
27f0289b6835
Merge the trunk changes in. Breaks socket.ssl for now.
Thomas Wouters <thomas@python.org>
parents:
42084
diff
changeset
|
119 # Synthesize all the other AllTests methods from the names in testmeths. |
|
21351
be990e703d0f
Fiddle test_class so it passes with -Qnew.
Tim Peters <tim.peters@gmail.com>
parents:
19406
diff
changeset
|
120 |
|
be990e703d0f
Fiddle test_class so it passes with -Qnew.
Tim Peters <tim.peters@gmail.com>
parents:
19406
diff
changeset
|
121 method_template = """\ |
|
42954
27f0289b6835
Merge the trunk changes in. Breaks socket.ssl for now.
Thomas Wouters <thomas@python.org>
parents:
42084
diff
changeset
|
122 @trackCall |
|
27f0289b6835
Merge the trunk changes in. Breaks socket.ssl for now.
Thomas Wouters <thomas@python.org>
parents:
42084
diff
changeset
|
123 def __%s__(self, *args): |
|
27f0289b6835
Merge the trunk changes in. Breaks socket.ssl for now.
Thomas Wouters <thomas@python.org>
parents:
42084
diff
changeset
|
124 pass |
|
21351
be990e703d0f
Fiddle test_class so it passes with -Qnew.
Tim Peters <tim.peters@gmail.com>
parents:
19406
diff
changeset
|
125 """ |
|
be990e703d0f
Fiddle test_class so it passes with -Qnew.
Tim Peters <tim.peters@gmail.com>
parents:
19406
diff
changeset
|
126 |
|
37743
7cae622edcc9
Make test_class work (but still fail) even though class.__dict__ is now a
Thomas Wouters <thomas@python.org>
parents:
37191
diff
changeset
|
127 d = {} |
|
42954
27f0289b6835
Merge the trunk changes in. Breaks socket.ssl for now.
Thomas Wouters <thomas@python.org>
parents:
42084
diff
changeset
|
128 exec(statictests, globals(), d) |
|
14037
91f847a783d2
Apply SF patch #101029: call __getitem__ with a proper slice object if there
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
129 for method in testmeths: |
|
42954
27f0289b6835
Merge the trunk changes in. Breaks socket.ssl for now.
Thomas Wouters <thomas@python.org>
parents:
42084
diff
changeset
|
130 exec(method_template % method, globals(), d) |
|
27f0289b6835
Merge the trunk changes in. Breaks socket.ssl for now.
Thomas Wouters <thomas@python.org>
parents:
42084
diff
changeset
|
131 AllTests = type("AllTests", (object,), d) |
|
27f0289b6835
Merge the trunk changes in. Breaks socket.ssl for now.
Thomas Wouters <thomas@python.org>
parents:
42084
diff
changeset
|
132 del d, statictests, method, method_template |
|
14037
91f847a783d2
Apply SF patch #101029: call __getitem__ with a proper slice object if there
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
133 |
|
42954
27f0289b6835
Merge the trunk changes in. Breaks socket.ssl for now.
Thomas Wouters <thomas@python.org>
parents:
42084
diff
changeset
|
134 class ClassTests(unittest.TestCase): |
|
27f0289b6835
Merge the trunk changes in. Breaks socket.ssl for now.
Thomas Wouters <thomas@python.org>
parents:
42084
diff
changeset
|
135 def setUp(self): |
|
27f0289b6835
Merge the trunk changes in. Breaks socket.ssl for now.
Thomas Wouters <thomas@python.org>
parents:
42084
diff
changeset
|
136 callLst[:] = [] |
|
14037
91f847a783d2
Apply SF patch #101029: call __getitem__ with a proper slice object if there
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
137 |
|
42954
27f0289b6835
Merge the trunk changes in. Breaks socket.ssl for now.
Thomas Wouters <thomas@python.org>
parents:
42084
diff
changeset
|
138 def assertCallStack(self, expected_calls): |
|
27f0289b6835
Merge the trunk changes in. Breaks socket.ssl for now.
Thomas Wouters <thomas@python.org>
parents:
42084
diff
changeset
|
139 actualCallList = callLst[:] # need to copy because the comparison below will add |
|
27f0289b6835
Merge the trunk changes in. Breaks socket.ssl for now.
Thomas Wouters <thomas@python.org>
parents:
42084
diff
changeset
|
140 # additional calls to callLst |
|
27f0289b6835
Merge the trunk changes in. Breaks socket.ssl for now.
Thomas Wouters <thomas@python.org>
parents:
42084
diff
changeset
|
141 if expected_calls != actualCallList: |
|
27f0289b6835
Merge the trunk changes in. Breaks socket.ssl for now.
Thomas Wouters <thomas@python.org>
parents:
42084
diff
changeset
|
142 self.fail("Expected call list:\n %s\ndoes not match actual call list\n %s" % |
|
27f0289b6835
Merge the trunk changes in. Breaks socket.ssl for now.
Thomas Wouters <thomas@python.org>
parents:
42084
diff
changeset
|
143 (expected_calls, actualCallList)) |
|
14037
91f847a783d2
Apply SF patch #101029: call __getitem__ with a proper slice object if there
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
144 |
|
42954
27f0289b6835
Merge the trunk changes in. Breaks socket.ssl for now.
Thomas Wouters <thomas@python.org>
parents:
42084
diff
changeset
|
145 def testInit(self): |
|
27f0289b6835
Merge the trunk changes in. Breaks socket.ssl for now.
Thomas Wouters <thomas@python.org>
parents:
42084
diff
changeset
|
146 foo = AllTests() |
|
27f0289b6835
Merge the trunk changes in. Breaks socket.ssl for now.
Thomas Wouters <thomas@python.org>
parents:
42084
diff
changeset
|
147 self.assertCallStack([("__init__", (foo,))]) |
|
14037
91f847a783d2
Apply SF patch #101029: call __getitem__ with a proper slice object if there
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
148 |
|
42954
27f0289b6835
Merge the trunk changes in. Breaks socket.ssl for now.
Thomas Wouters <thomas@python.org>
parents:
42084
diff
changeset
|
149 def testBinaryOps(self): |
|
27f0289b6835
Merge the trunk changes in. Breaks socket.ssl for now.
Thomas Wouters <thomas@python.org>
parents:
42084
diff
changeset
|
150 testme = AllTests() |
|
27f0289b6835
Merge the trunk changes in. Breaks socket.ssl for now.
Thomas Wouters <thomas@python.org>
parents:
42084
diff
changeset
|
151 # Binary operations |
|
14037
91f847a783d2
Apply SF patch #101029: call __getitem__ with a proper slice object if there
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
152 |
|
42954
27f0289b6835
Merge the trunk changes in. Breaks socket.ssl for now.
Thomas Wouters <thomas@python.org>
parents:
42084
diff
changeset
|
153 callLst[:] = [] |
|
27f0289b6835
Merge the trunk changes in. Breaks socket.ssl for now.
Thomas Wouters <thomas@python.org>
parents:
42084
diff
changeset
|
154 testme + 1 |
|
27f0289b6835
Merge the trunk changes in. Breaks socket.ssl for now.
Thomas Wouters <thomas@python.org>
parents:
42084
diff
changeset
|
155 self.assertCallStack([("__add__", (testme, 1))]) |
|
27f0289b6835
Merge the trunk changes in. Breaks socket.ssl for now.
Thomas Wouters <thomas@python.org>
parents:
42084
diff
changeset
|
156 |
|
27f0289b6835
Merge the trunk changes in. Breaks socket.ssl for now.
Thomas Wouters <thomas@python.org>
parents:
42084
diff
changeset
|
157 callLst[:] = [] |
|
27f0289b6835
Merge the trunk changes in. Breaks socket.ssl for now.
Thomas Wouters <thomas@python.org>
parents:
42084
diff
changeset
|
158 1 + testme |
|
27f0289b6835
Merge the trunk changes in. Breaks socket.ssl for now.
Thomas Wouters <thomas@python.org>
parents:
42084
diff
changeset
|
159 self.assertCallStack([("__radd__", (testme, 1))]) |
|
14037
91f847a783d2
Apply SF patch #101029: call __getitem__ with a proper slice object if there
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
160 |
|
42954
27f0289b6835
Merge the trunk changes in. Breaks socket.ssl for now.
Thomas Wouters <thomas@python.org>
parents:
42084
diff
changeset
|
161 callLst[:] = [] |
|
27f0289b6835
Merge the trunk changes in. Breaks socket.ssl for now.
Thomas Wouters <thomas@python.org>
parents:
42084
diff
changeset
|
162 testme - 1 |
|
27f0289b6835
Merge the trunk changes in. Breaks socket.ssl for now.
Thomas Wouters <thomas@python.org>
parents:
42084
diff
changeset
|
163 self.assertCallStack([("__sub__", (testme, 1))]) |
|
14037
91f847a783d2
Apply SF patch #101029: call __getitem__ with a proper slice object if there
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
164 |
|
42954
27f0289b6835
Merge the trunk changes in. Breaks socket.ssl for now.
Thomas Wouters <thomas@python.org>
parents:
42084
diff
changeset
|
165 callLst[:] = [] |
|
27f0289b6835
Merge the trunk changes in. Breaks socket.ssl for now.
Thomas Wouters <thomas@python.org>
parents:
42084
diff
changeset
|
166 1 - testme |
|
27f0289b6835
Merge the trunk changes in. Breaks socket.ssl for now.
Thomas Wouters <thomas@python.org>
parents:
42084
diff
changeset
|
167 self.assertCallStack([("__rsub__", (testme, 1))]) |
|
14037
91f847a783d2
Apply SF patch #101029: call __getitem__ with a proper slice object if there
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
168 |
|
42954
27f0289b6835
Merge the trunk changes in. Breaks socket.ssl for now.
Thomas Wouters <thomas@python.org>
parents:
42084
diff
changeset
|
169 callLst[:] = [] |
|
27f0289b6835
Merge the trunk changes in. Breaks socket.ssl for now.
Thomas Wouters <thomas@python.org>
parents:
42084
diff
changeset
|
170 testme * 1 |
|
27f0289b6835
Merge the trunk changes in. Breaks socket.ssl for now.
Thomas Wouters <thomas@python.org>
parents:
42084
diff
changeset
|
171 self.assertCallStack([("__mul__", (testme, 1))]) |
|
14037
91f847a783d2
Apply SF patch #101029: call __getitem__ with a proper slice object if there
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
172 |
|
42954
27f0289b6835
Merge the trunk changes in. Breaks socket.ssl for now.
Thomas Wouters <thomas@python.org>
parents:
42084
diff
changeset
|
173 callLst[:] = [] |
|
27f0289b6835
Merge the trunk changes in. Breaks socket.ssl for now.
Thomas Wouters <thomas@python.org>
parents:
42084
diff
changeset
|
174 1 * testme |
|
27f0289b6835
Merge the trunk changes in. Breaks socket.ssl for now.
Thomas Wouters <thomas@python.org>
parents:
42084
diff
changeset
|
175 self.assertCallStack([("__rmul__", (testme, 1))]) |
|
14037
91f847a783d2
Apply SF patch #101029: call __getitem__ with a proper slice object if there
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
176 |
|
42954
27f0289b6835
Merge the trunk changes in. Breaks socket.ssl for now.
Thomas Wouters <thomas@python.org>
parents:
42084
diff
changeset
|
177 if 1/2 == 0: |
|
27f0289b6835
Merge the trunk changes in. Breaks socket.ssl for now.
Thomas Wouters <thomas@python.org>
parents:
42084
diff
changeset
|
178 callLst[:] = [] |
|
27f0289b6835
Merge the trunk changes in. Breaks socket.ssl for now.
Thomas Wouters <thomas@python.org>
parents:
42084
diff
changeset
|
179 testme / 1 |
|
27f0289b6835
Merge the trunk changes in. Breaks socket.ssl for now.
Thomas Wouters <thomas@python.org>
parents:
42084
diff
changeset
|
180 self.assertCallStack([("__div__", (testme, 1))]) |
|
14037
91f847a783d2
Apply SF patch #101029: call __getitem__ with a proper slice object if there
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
181 |
|
91f847a783d2
Apply SF patch #101029: call __getitem__ with a proper slice object if there
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
182 |
|
42954
27f0289b6835
Merge the trunk changes in. Breaks socket.ssl for now.
Thomas Wouters <thomas@python.org>
parents:
42084
diff
changeset
|
183 callLst[:] = [] |
|
27f0289b6835
Merge the trunk changes in. Breaks socket.ssl for now.
Thomas Wouters <thomas@python.org>
parents:
42084
diff
changeset
|
184 1 / testme |
|
27f0289b6835
Merge the trunk changes in. Breaks socket.ssl for now.
Thomas Wouters <thomas@python.org>
parents:
42084
diff
changeset
|
185 self.assertCallStack([("__rdiv__", (testme, 1))]) |
|
14037
91f847a783d2
Apply SF patch #101029: call __getitem__ with a proper slice object if there
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
186 |
|
42954
27f0289b6835
Merge the trunk changes in. Breaks socket.ssl for now.
Thomas Wouters <thomas@python.org>
parents:
42084
diff
changeset
|
187 callLst[:] = [] |
|
27f0289b6835
Merge the trunk changes in. Breaks socket.ssl for now.
Thomas Wouters <thomas@python.org>
parents:
42084
diff
changeset
|
188 testme % 1 |
|
27f0289b6835
Merge the trunk changes in. Breaks socket.ssl for now.
Thomas Wouters <thomas@python.org>
parents:
42084
diff
changeset
|
189 self.assertCallStack([("__mod__", (testme, 1))]) |
|
27f0289b6835
Merge the trunk changes in. Breaks socket.ssl for now.
Thomas Wouters <thomas@python.org>
parents:
42084
diff
changeset
|
190 |
|
27f0289b6835
Merge the trunk changes in. Breaks socket.ssl for now.
Thomas Wouters <thomas@python.org>
parents:
42084
diff
changeset
|
191 callLst[:] = [] |
|
27f0289b6835
Merge the trunk changes in. Breaks socket.ssl for now.
Thomas Wouters <thomas@python.org>
parents:
42084
diff
changeset
|
192 1 % testme |
|
27f0289b6835
Merge the trunk changes in. Breaks socket.ssl for now.
Thomas Wouters <thomas@python.org>
parents:
42084
diff
changeset
|
193 self.assertCallStack([("__rmod__", (testme, 1))]) |
|
14037
91f847a783d2
Apply SF patch #101029: call __getitem__ with a proper slice object if there
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
194 |
|
91f847a783d2
Apply SF patch #101029: call __getitem__ with a proper slice object if there
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
195 |
|
42954
27f0289b6835
Merge the trunk changes in. Breaks socket.ssl for now.
Thomas Wouters <thomas@python.org>
parents:
42084
diff
changeset
|
196 callLst[:] = [] |
|
27f0289b6835
Merge the trunk changes in. Breaks socket.ssl for now.
Thomas Wouters <thomas@python.org>
parents:
42084
diff
changeset
|
197 divmod(testme,1) |
|
27f0289b6835
Merge the trunk changes in. Breaks socket.ssl for now.
Thomas Wouters <thomas@python.org>
parents:
42084
diff
changeset
|
198 self.assertCallStack([("__divmod__", (testme, 1))]) |
|
27f0289b6835
Merge the trunk changes in. Breaks socket.ssl for now.
Thomas Wouters <thomas@python.org>
parents:
42084
diff
changeset
|
199 |
|
27f0289b6835
Merge the trunk changes in. Breaks socket.ssl for now.
Thomas Wouters <thomas@python.org>
parents:
42084
diff
changeset
|
200 callLst[:] = [] |
|
27f0289b6835
Merge the trunk changes in. Breaks socket.ssl for now.
Thomas Wouters <thomas@python.org>
parents:
42084
diff
changeset
|
201 divmod(1, testme) |
|
27f0289b6835
Merge the trunk changes in. Breaks socket.ssl for now.
Thomas Wouters <thomas@python.org>
parents:
42084
diff
changeset
|
202 self.assertCallStack([("__rdivmod__", (testme, 1))]) |
|
27f0289b6835
Merge the trunk changes in. Breaks socket.ssl for now.
Thomas Wouters <thomas@python.org>
parents:
42084
diff
changeset
|
203 |
|
27f0289b6835
Merge the trunk changes in. Breaks socket.ssl for now.
Thomas Wouters <thomas@python.org>
parents:
42084
diff
changeset
|
204 callLst[:] = [] |
|
27f0289b6835
Merge the trunk changes in. Breaks socket.ssl for now.
Thomas Wouters <thomas@python.org>
parents:
42084
diff
changeset
|
205 testme ** 1 |
|
27f0289b6835
Merge the trunk changes in. Breaks socket.ssl for now.
Thomas Wouters <thomas@python.org>
parents:
42084
diff
changeset
|
206 self.assertCallStack([("__pow__", (testme, 1))]) |
|
27f0289b6835
Merge the trunk changes in. Breaks socket.ssl for now.
Thomas Wouters <thomas@python.org>
parents:
42084
diff
changeset
|
207 |
|
27f0289b6835
Merge the trunk changes in. Breaks socket.ssl for now.
Thomas Wouters <thomas@python.org>
parents:
42084
diff
changeset
|
208 callLst[:] = [] |
|
27f0289b6835
Merge the trunk changes in. Breaks socket.ssl for now.
Thomas Wouters <thomas@python.org>
parents:
42084
diff
changeset
|
209 1 ** testme |
|
27f0289b6835
Merge the trunk changes in. Breaks socket.ssl for now.
Thomas Wouters <thomas@python.org>
parents:
42084
diff
changeset
|
210 self.assertCallStack([("__rpow__", (testme, 1))]) |
|
14037
91f847a783d2
Apply SF patch #101029: call __getitem__ with a proper slice object if there
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
211 |
|
42954
27f0289b6835
Merge the trunk changes in. Breaks socket.ssl for now.
Thomas Wouters <thomas@python.org>
parents:
42084
diff
changeset
|
212 callLst[:] = [] |
|
27f0289b6835
Merge the trunk changes in. Breaks socket.ssl for now.
Thomas Wouters <thomas@python.org>
parents:
42084
diff
changeset
|
213 testme >> 1 |
|
27f0289b6835
Merge the trunk changes in. Breaks socket.ssl for now.
Thomas Wouters <thomas@python.org>
parents:
42084
diff
changeset
|
214 self.assertCallStack([("__rshift__", (testme, 1))]) |
|
27f0289b6835
Merge the trunk changes in. Breaks socket.ssl for now.
Thomas Wouters <thomas@python.org>
parents:
42084
diff
changeset
|
215 |
|
27f0289b6835
Merge the trunk changes in. Breaks socket.ssl for now.
Thomas Wouters <thomas@python.org>
parents:
42084
diff
changeset
|
216 callLst[:] = [] |
|
27f0289b6835
Merge the trunk changes in. Breaks socket.ssl for now.
Thomas Wouters <thomas@python.org>
parents:
42084
diff
changeset
|
217 1 >> testme |
|
27f0289b6835
Merge the trunk changes in. Breaks socket.ssl for now.
Thomas Wouters <thomas@python.org>
parents:
42084
diff
changeset
|
218 self.assertCallStack([("__rrshift__", (testme, 1))]) |
|
27f0289b6835
Merge the trunk changes in. Breaks socket.ssl for now.
Thomas Wouters <thomas@python.org>
parents:
42084
diff
changeset
|
219 |
|
27f0289b6835
Merge the trunk changes in. Breaks socket.ssl for now.
Thomas Wouters <thomas@python.org>
parents:
42084
diff
changeset
|
220 callLst[:] = [] |
|
27f0289b6835
Merge the trunk changes in. Breaks socket.ssl for now.
Thomas Wouters <thomas@python.org>
parents:
42084
diff
changeset
|
221 testme << 1 |
|
27f0289b6835
Merge the trunk changes in. Breaks socket.ssl for now.
Thomas Wouters <thomas@python.org>
parents:
42084
diff
changeset
|
222 self.assertCallStack([("__lshift__", (testme, 1))]) |
|
27f0289b6835
Merge the trunk changes in. Breaks socket.ssl for now.
Thomas Wouters <thomas@python.org>
parents:
42084
diff
changeset
|
223 |
|
27f0289b6835
Merge the trunk changes in. Breaks socket.ssl for now.
Thomas Wouters <thomas@python.org>
parents:
42084
diff
changeset
|
224 callLst[:] = [] |
|
27f0289b6835
Merge the trunk changes in. Breaks socket.ssl for now.
Thomas Wouters <thomas@python.org>
parents:
42084
diff
changeset
|
225 1 << testme |
|
27f0289b6835
Merge the trunk changes in. Breaks socket.ssl for now.
Thomas Wouters <thomas@python.org>
parents:
42084
diff
changeset
|
226 self.assertCallStack([("__rlshift__", (testme, 1))]) |
|
27f0289b6835
Merge the trunk changes in. Breaks socket.ssl for now.
Thomas Wouters <thomas@python.org>
parents:
42084
diff
changeset
|
227 |
|
27f0289b6835
Merge the trunk changes in. Breaks socket.ssl for now.
Thomas Wouters <thomas@python.org>
parents:
42084
diff
changeset
|
228 callLst[:] = [] |
|
27f0289b6835
Merge the trunk changes in. Breaks socket.ssl for now.
Thomas Wouters <thomas@python.org>
parents:
42084
diff
changeset
|
229 testme & 1 |
|
27f0289b6835
Merge the trunk changes in. Breaks socket.ssl for now.
Thomas Wouters <thomas@python.org>
parents:
42084
diff
changeset
|
230 self.assertCallStack([("__and__", (testme, 1))]) |
|
40450
cc992d75d5b3
Four months of trunk changes (including a few releases...)
Thomas Wouters <thomas@python.org>
parents:
39782
diff
changeset
|
231 |
|
42954
27f0289b6835
Merge the trunk changes in. Breaks socket.ssl for now.
Thomas Wouters <thomas@python.org>
parents:
42084
diff
changeset
|
232 callLst[:] = [] |
|
27f0289b6835
Merge the trunk changes in. Breaks socket.ssl for now.
Thomas Wouters <thomas@python.org>
parents:
42084
diff
changeset
|
233 1 & testme |
|
27f0289b6835
Merge the trunk changes in. Breaks socket.ssl for now.
Thomas Wouters <thomas@python.org>
parents:
42084
diff
changeset
|
234 self.assertCallStack([("__rand__", (testme, 1))]) |
|
27f0289b6835
Merge the trunk changes in. Breaks socket.ssl for now.
Thomas Wouters <thomas@python.org>
parents:
42084
diff
changeset
|
235 |
|
27f0289b6835
Merge the trunk changes in. Breaks socket.ssl for now.
Thomas Wouters <thomas@python.org>
parents:
42084
diff
changeset
|
236 callLst[:] = [] |
|
27f0289b6835
Merge the trunk changes in. Breaks socket.ssl for now.
Thomas Wouters <thomas@python.org>
parents:
42084
diff
changeset
|
237 testme | 1 |
|
27f0289b6835
Merge the trunk changes in. Breaks socket.ssl for now.
Thomas Wouters <thomas@python.org>
parents:
42084
diff
changeset
|
238 self.assertCallStack([("__or__", (testme, 1))]) |
|
27f0289b6835
Merge the trunk changes in. Breaks socket.ssl for now.
Thomas Wouters <thomas@python.org>
parents:
42084
diff
changeset
|
239 |
|
27f0289b6835
Merge the trunk changes in. Breaks socket.ssl for now.
Thomas Wouters <thomas@python.org>
parents:
42084
diff
changeset
|
240 callLst[:] = [] |
|
27f0289b6835
Merge the trunk changes in. Breaks socket.ssl for now.
Thomas Wouters <thomas@python.org>
parents:
42084
diff
changeset
|
241 1 | testme |
|
27f0289b6835
Merge the trunk changes in. Breaks socket.ssl for now.
Thomas Wouters <thomas@python.org>
parents:
42084
diff
changeset
|
242 self.assertCallStack([("__ror__", (testme, 1))]) |
|
27f0289b6835
Merge the trunk changes in. Breaks socket.ssl for now.
Thomas Wouters <thomas@python.org>
parents:
42084
diff
changeset
|
243 |
|
27f0289b6835
Merge the trunk changes in. Breaks socket.ssl for now.
Thomas Wouters <thomas@python.org>
parents:
42084
diff
changeset
|
244 callLst[:] = [] |
|
27f0289b6835
Merge the trunk changes in. Breaks socket.ssl for now.
Thomas Wouters <thomas@python.org>
parents:
42084
diff
changeset
|
245 testme ^ 1 |
|
27f0289b6835
Merge the trunk changes in. Breaks socket.ssl for now.
Thomas Wouters <thomas@python.org>
parents:
42084
diff
changeset
|
246 self.assertCallStack([("__xor__", (testme, 1))]) |
|
27f0289b6835
Merge the trunk changes in. Breaks socket.ssl for now.
Thomas Wouters <thomas@python.org>
parents:
42084
diff
changeset
|
247 |
|
27f0289b6835
Merge the trunk changes in. Breaks socket.ssl for now.
Thomas Wouters <thomas@python.org>
parents:
42084
diff
changeset
|
248 callLst[:] = [] |
|
27f0289b6835
Merge the trunk changes in. Breaks socket.ssl for now.
Thomas Wouters <thomas@python.org>
parents:
42084
diff
changeset
|
249 1 ^ testme |
|
27f0289b6835
Merge the trunk changes in. Breaks socket.ssl for now.
Thomas Wouters <thomas@python.org>
parents:
42084
diff
changeset
|
250 self.assertCallStack([("__rxor__", (testme, 1))]) |
|
40450
cc992d75d5b3
Four months of trunk changes (including a few releases...)
Thomas Wouters <thomas@python.org>
parents:
39782
diff
changeset
|
251 |
|
42954
27f0289b6835
Merge the trunk changes in. Breaks socket.ssl for now.
Thomas Wouters <thomas@python.org>
parents:
42084
diff
changeset
|
252 def testListAndDictOps(self): |
|
27f0289b6835
Merge the trunk changes in. Breaks socket.ssl for now.
Thomas Wouters <thomas@python.org>
parents:
42084
diff
changeset
|
253 testme = AllTests() |
|
27f0289b6835
Merge the trunk changes in. Breaks socket.ssl for now.
Thomas Wouters <thomas@python.org>
parents:
42084
diff
changeset
|
254 |
|
27f0289b6835
Merge the trunk changes in. Breaks socket.ssl for now.
Thomas Wouters <thomas@python.org>
parents:
42084
diff
changeset
|
255 # List/dict operations |
|
27f0289b6835
Merge the trunk changes in. Breaks socket.ssl for now.
Thomas Wouters <thomas@python.org>
parents:
42084
diff
changeset
|
256 |
|
27f0289b6835
Merge the trunk changes in. Breaks socket.ssl for now.
Thomas Wouters <thomas@python.org>
parents:
42084
diff
changeset
|
257 class Empty: pass |
|
27f0289b6835
Merge the trunk changes in. Breaks socket.ssl for now.
Thomas Wouters <thomas@python.org>
parents:
42084
diff
changeset
|
258 |
|
27f0289b6835
Merge the trunk changes in. Breaks socket.ssl for now.
Thomas Wouters <thomas@python.org>
parents:
42084
diff
changeset
|
259 try: |
|
27f0289b6835
Merge the trunk changes in. Breaks socket.ssl for now.
Thomas Wouters <thomas@python.org>
parents:
42084
diff
changeset
|
260 1 in Empty() |
|
27f0289b6835
Merge the trunk changes in. Breaks socket.ssl for now.
Thomas Wouters <thomas@python.org>
parents:
42084
diff
changeset
|
261 self.fail('failed, should have raised TypeError') |
|
27f0289b6835
Merge the trunk changes in. Breaks socket.ssl for now.
Thomas Wouters <thomas@python.org>
parents:
42084
diff
changeset
|
262 except TypeError: |
|
27f0289b6835
Merge the trunk changes in. Breaks socket.ssl for now.
Thomas Wouters <thomas@python.org>
parents:
42084
diff
changeset
|
263 pass |
|
27f0289b6835
Merge the trunk changes in. Breaks socket.ssl for now.
Thomas Wouters <thomas@python.org>
parents:
42084
diff
changeset
|
264 |
|
27f0289b6835
Merge the trunk changes in. Breaks socket.ssl for now.
Thomas Wouters <thomas@python.org>
parents:
42084
diff
changeset
|
265 callLst[:] = [] |
|
27f0289b6835
Merge the trunk changes in. Breaks socket.ssl for now.
Thomas Wouters <thomas@python.org>
parents:
42084
diff
changeset
|
266 1 in testme |
|
27f0289b6835
Merge the trunk changes in. Breaks socket.ssl for now.
Thomas Wouters <thomas@python.org>
parents:
42084
diff
changeset
|
267 self.assertCallStack([('__contains__', (testme, 1))]) |
|
27f0289b6835
Merge the trunk changes in. Breaks socket.ssl for now.
Thomas Wouters <thomas@python.org>
parents:
42084
diff
changeset
|
268 |
|
27f0289b6835
Merge the trunk changes in. Breaks socket.ssl for now.
Thomas Wouters <thomas@python.org>
parents:
42084
diff
changeset
|
269 callLst[:] = [] |
|
27f0289b6835
Merge the trunk changes in. Breaks socket.ssl for now.
Thomas Wouters <thomas@python.org>
parents:
42084
diff
changeset
|
270 testme[1] |
|
27f0289b6835
Merge the trunk changes in. Breaks socket.ssl for now.
Thomas Wouters <thomas@python.org>
parents:
42084
diff
changeset
|
271 self.assertCallStack([('__getitem__', (testme, 1))]) |
|
14037
91f847a783d2
Apply SF patch #101029: call __getitem__ with a proper slice object if there
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
272 |
|
42954
27f0289b6835
Merge the trunk changes in. Breaks socket.ssl for now.
Thomas Wouters <thomas@python.org>
parents:
42084
diff
changeset
|
273 callLst[:] = [] |
|
27f0289b6835
Merge the trunk changes in. Breaks socket.ssl for now.
Thomas Wouters <thomas@python.org>
parents:
42084
diff
changeset
|
274 testme[1] = 1 |
|
27f0289b6835
Merge the trunk changes in. Breaks socket.ssl for now.
Thomas Wouters <thomas@python.org>
parents:
42084
diff
changeset
|
275 self.assertCallStack([('__setitem__', (testme, 1, 1))]) |
|
27f0289b6835
Merge the trunk changes in. Breaks socket.ssl for now.
Thomas Wouters <thomas@python.org>
parents:
42084
diff
changeset
|
276 |
|
27f0289b6835
Merge the trunk changes in. Breaks socket.ssl for now.
Thomas Wouters <thomas@python.org>
parents:
42084
diff
changeset
|
277 callLst[:] = [] |
|
27f0289b6835
Merge the trunk changes in. Breaks socket.ssl for now.
Thomas Wouters <thomas@python.org>
parents:
42084
diff
changeset
|
278 del testme[1] |
|
27f0289b6835
Merge the trunk changes in. Breaks socket.ssl for now.
Thomas Wouters <thomas@python.org>
parents:
42084
diff
changeset
|
279 self.assertCallStack([('__delitem__', (testme, 1))]) |
|
27f0289b6835
Merge the trunk changes in. Breaks socket.ssl for now.
Thomas Wouters <thomas@python.org>
parents:
42084
diff
changeset
|
280 |
|
27f0289b6835
Merge the trunk changes in. Breaks socket.ssl for now.
Thomas Wouters <thomas@python.org>
parents:
42084
diff
changeset
|
281 callLst[:] = [] |
|
27f0289b6835
Merge the trunk changes in. Breaks socket.ssl for now.
Thomas Wouters <thomas@python.org>
parents:
42084
diff
changeset
|
282 testme[:42] |
|
43100
4e6b4ba60c3b
Remove the simple slicing API. All slicing is now done with slice objects.
Thomas Wouters <thomas@python.org>
parents:
42954
diff
changeset
|
283 self.assertCallStack([('__getitem__', (testme, slice(None, 42)))]) |
|
42954
27f0289b6835
Merge the trunk changes in. Breaks socket.ssl for now.
Thomas Wouters <thomas@python.org>
parents:
42084
diff
changeset
|
284 |
|
27f0289b6835
Merge the trunk changes in. Breaks socket.ssl for now.
Thomas Wouters <thomas@python.org>
parents:
42084
diff
changeset
|
285 callLst[:] = [] |
|
27f0289b6835
Merge the trunk changes in. Breaks socket.ssl for now.
Thomas Wouters <thomas@python.org>
parents:
42084
diff
changeset
|
286 testme[:42] = "The Answer" |
|
43100
4e6b4ba60c3b
Remove the simple slicing API. All slicing is now done with slice objects.
Thomas Wouters <thomas@python.org>
parents:
42954
diff
changeset
|
287 self.assertCallStack([('__setitem__', (testme, slice(None, 42), |
|
4e6b4ba60c3b
Remove the simple slicing API. All slicing is now done with slice objects.
Thomas Wouters <thomas@python.org>
parents:
42954
diff
changeset
|
288 "The Answer"))]) |
|
14037
91f847a783d2
Apply SF patch #101029: call __getitem__ with a proper slice object if there
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
289 |
|
42954
27f0289b6835
Merge the trunk changes in. Breaks socket.ssl for now.
Thomas Wouters <thomas@python.org>
parents:
42084
diff
changeset
|
290 callLst[:] = [] |
|
27f0289b6835
Merge the trunk changes in. Breaks socket.ssl for now.
Thomas Wouters <thomas@python.org>
parents:
42084
diff
changeset
|
291 del testme[:42] |
|
43100
4e6b4ba60c3b
Remove the simple slicing API. All slicing is now done with slice objects.
Thomas Wouters <thomas@python.org>
parents:
42954
diff
changeset
|
292 self.assertCallStack([('__delitem__', (testme, slice(None, 42)))]) |
|
42954
27f0289b6835
Merge the trunk changes in. Breaks socket.ssl for now.
Thomas Wouters <thomas@python.org>
parents:
42084
diff
changeset
|
293 |
|
27f0289b6835
Merge the trunk changes in. Breaks socket.ssl for now.
Thomas Wouters <thomas@python.org>
parents:
42084
diff
changeset
|
294 callLst[:] = [] |
|
27f0289b6835
Merge the trunk changes in. Breaks socket.ssl for now.
Thomas Wouters <thomas@python.org>
parents:
42084
diff
changeset
|
295 testme[2:1024:10] |
|
27f0289b6835
Merge the trunk changes in. Breaks socket.ssl for now.
Thomas Wouters <thomas@python.org>
parents:
42084
diff
changeset
|
296 self.assertCallStack([('__getitem__', (testme, slice(2, 1024, 10)))]) |
|
27f0289b6835
Merge the trunk changes in. Breaks socket.ssl for now.
Thomas Wouters <thomas@python.org>
parents:
42084
diff
changeset
|
297 |
|
27f0289b6835
Merge the trunk changes in. Breaks socket.ssl for now.
Thomas Wouters <thomas@python.org>
parents:
42084
diff
changeset
|
298 callLst[:] = [] |
|
27f0289b6835
Merge the trunk changes in. Breaks socket.ssl for now.
Thomas Wouters <thomas@python.org>
parents:
42084
diff
changeset
|
299 testme[2:1024:10] = "A lot" |
|
27f0289b6835
Merge the trunk changes in. Breaks socket.ssl for now.
Thomas Wouters <thomas@python.org>
parents:
42084
diff
changeset
|
300 self.assertCallStack([('__setitem__', (testme, slice(2, 1024, 10), |
|
27f0289b6835
Merge the trunk changes in. Breaks socket.ssl for now.
Thomas Wouters <thomas@python.org>
parents:
42084
diff
changeset
|
301 "A lot"))]) |
|
27f0289b6835
Merge the trunk changes in. Breaks socket.ssl for now.
Thomas Wouters <thomas@python.org>
parents:
42084
diff
changeset
|
302 callLst[:] = [] |
|
27f0289b6835
Merge the trunk changes in. Breaks socket.ssl for now.
Thomas Wouters <thomas@python.org>
parents:
42084
diff
changeset
|
303 del testme[2:1024:10] |
|
27f0289b6835
Merge the trunk changes in. Breaks socket.ssl for now.
Thomas Wouters <thomas@python.org>
parents:
42084
diff
changeset
|
304 self.assertCallStack([('__delitem__', (testme, slice(2, 1024, 10)))]) |
|
14037
91f847a783d2
Apply SF patch #101029: call __getitem__ with a proper slice object if there
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
305 |
|
42954
27f0289b6835
Merge the trunk changes in. Breaks socket.ssl for now.
Thomas Wouters <thomas@python.org>
parents:
42084
diff
changeset
|
306 callLst[:] = [] |
|
27f0289b6835
Merge the trunk changes in. Breaks socket.ssl for now.
Thomas Wouters <thomas@python.org>
parents:
42084
diff
changeset
|
307 testme[:42, ..., :24:, 24, 100] |
|
27f0289b6835
Merge the trunk changes in. Breaks socket.ssl for now.
Thomas Wouters <thomas@python.org>
parents:
42084
diff
changeset
|
308 self.assertCallStack([('__getitem__', (testme, (slice(None, 42, None), |
|
27f0289b6835
Merge the trunk changes in. Breaks socket.ssl for now.
Thomas Wouters <thomas@python.org>
parents:
42084
diff
changeset
|
309 Ellipsis, |
|
27f0289b6835
Merge the trunk changes in. Breaks socket.ssl for now.
Thomas Wouters <thomas@python.org>
parents:
42084
diff
changeset
|
310 slice(None, 24, None), |
|
27f0289b6835
Merge the trunk changes in. Breaks socket.ssl for now.
Thomas Wouters <thomas@python.org>
parents:
42084
diff
changeset
|
311 24, 100)))]) |
|
27f0289b6835
Merge the trunk changes in. Breaks socket.ssl for now.
Thomas Wouters <thomas@python.org>
parents:
42084
diff
changeset
|
312 callLst[:] = [] |
|
27f0289b6835
Merge the trunk changes in. Breaks socket.ssl for now.
Thomas Wouters <thomas@python.org>
parents:
42084
diff
changeset
|
313 testme[:42, ..., :24:, 24, 100] = "Strange" |
|
27f0289b6835
Merge the trunk changes in. Breaks socket.ssl for now.
Thomas Wouters <thomas@python.org>
parents:
42084
diff
changeset
|
314 self.assertCallStack([('__setitem__', (testme, (slice(None, 42, None), |
|
27f0289b6835
Merge the trunk changes in. Breaks socket.ssl for now.
Thomas Wouters <thomas@python.org>
parents:
42084
diff
changeset
|
315 Ellipsis, |
|
27f0289b6835
Merge the trunk changes in. Breaks socket.ssl for now.
Thomas Wouters <thomas@python.org>
parents:
42084
diff
changeset
|
316 slice(None, 24, None), |
|
27f0289b6835
Merge the trunk changes in. Breaks socket.ssl for now.
Thomas Wouters <thomas@python.org>
parents:
42084
diff
changeset
|
317 24, 100), "Strange"))]) |
|
27f0289b6835
Merge the trunk changes in. Breaks socket.ssl for now.
Thomas Wouters <thomas@python.org>
parents:
42084
diff
changeset
|
318 callLst[:] = [] |
|
27f0289b6835
Merge the trunk changes in. Breaks socket.ssl for now.
Thomas Wouters <thomas@python.org>
parents:
42084
diff
changeset
|
319 del testme[:42, ..., :24:, 24, 100] |
|
27f0289b6835
Merge the trunk changes in. Breaks socket.ssl for now.
Thomas Wouters <thomas@python.org>
parents:
42084
diff
changeset
|
320 self.assertCallStack([('__delitem__', (testme, (slice(None, 42, None), |
|
27f0289b6835
Merge the trunk changes in. Breaks socket.ssl for now.
Thomas Wouters <thomas@python.org>
parents:
42084
diff
changeset
|
321 Ellipsis, |
|
27f0289b6835
Merge the trunk changes in. Breaks socket.ssl for now.
Thomas Wouters <thomas@python.org>
parents:
42084
diff
changeset
|
322 slice(None, 24, None), |
|
27f0289b6835
Merge the trunk changes in. Breaks socket.ssl for now.
Thomas Wouters <thomas@python.org>
parents:
42084
diff
changeset
|
323 24, 100)))]) |
|
27f0289b6835
Merge the trunk changes in. Breaks socket.ssl for now.
Thomas Wouters <thomas@python.org>
parents:
42084
diff
changeset
|
324 |
|
27f0289b6835
Merge the trunk changes in. Breaks socket.ssl for now.
Thomas Wouters <thomas@python.org>
parents:
42084
diff
changeset
|
325 def testUnaryOps(self): |
|
27f0289b6835
Merge the trunk changes in. Breaks socket.ssl for now.
Thomas Wouters <thomas@python.org>
parents:
42084
diff
changeset
|
326 testme = AllTests() |
|
14037
91f847a783d2
Apply SF patch #101029: call __getitem__ with a proper slice object if there
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
327 |
|
42954
27f0289b6835
Merge the trunk changes in. Breaks socket.ssl for now.
Thomas Wouters <thomas@python.org>
parents:
42084
diff
changeset
|
328 callLst[:] = [] |
|
27f0289b6835
Merge the trunk changes in. Breaks socket.ssl for now.
Thomas Wouters <thomas@python.org>
parents:
42084
diff
changeset
|
329 -testme |
|
27f0289b6835
Merge the trunk changes in. Breaks socket.ssl for now.
Thomas Wouters <thomas@python.org>
parents:
42084
diff
changeset
|
330 self.assertCallStack([('__neg__', (testme,))]) |
|
27f0289b6835
Merge the trunk changes in. Breaks socket.ssl for now.
Thomas Wouters <thomas@python.org>
parents:
42084
diff
changeset
|
331 callLst[:] = [] |
|
27f0289b6835
Merge the trunk changes in. Breaks socket.ssl for now.
Thomas Wouters <thomas@python.org>
parents:
42084
diff
changeset
|
332 +testme |
|
27f0289b6835
Merge the trunk changes in. Breaks socket.ssl for now.
Thomas Wouters <thomas@python.org>
parents:
42084
diff
changeset
|
333 self.assertCallStack([('__pos__', (testme,))]) |
|
27f0289b6835
Merge the trunk changes in. Breaks socket.ssl for now.
Thomas Wouters <thomas@python.org>
parents:
42084
diff
changeset
|
334 callLst[:] = [] |
|
27f0289b6835
Merge the trunk changes in. Breaks socket.ssl for now.
Thomas Wouters <thomas@python.org>
parents:
42084
diff
changeset
|
335 abs(testme) |
|
27f0289b6835
Merge the trunk changes in. Breaks socket.ssl for now.
Thomas Wouters <thomas@python.org>
parents:
42084
diff
changeset
|
336 self.assertCallStack([('__abs__', (testme,))]) |
|
27f0289b6835
Merge the trunk changes in. Breaks socket.ssl for now.
Thomas Wouters <thomas@python.org>
parents:
42084
diff
changeset
|
337 callLst[:] = [] |
|
27f0289b6835
Merge the trunk changes in. Breaks socket.ssl for now.
Thomas Wouters <thomas@python.org>
parents:
42084
diff
changeset
|
338 int(testme) |
|
27f0289b6835
Merge the trunk changes in. Breaks socket.ssl for now.
Thomas Wouters <thomas@python.org>
parents:
42084
diff
changeset
|
339 self.assertCallStack([('__int__', (testme,))]) |
|
27f0289b6835
Merge the trunk changes in. Breaks socket.ssl for now.
Thomas Wouters <thomas@python.org>
parents:
42084
diff
changeset
|
340 callLst[:] = [] |
|
27f0289b6835
Merge the trunk changes in. Breaks socket.ssl for now.
Thomas Wouters <thomas@python.org>
parents:
42084
diff
changeset
|
341 float(testme) |
|
27f0289b6835
Merge the trunk changes in. Breaks socket.ssl for now.
Thomas Wouters <thomas@python.org>
parents:
42084
diff
changeset
|
342 self.assertCallStack([('__float__', (testme,))]) |
|
27f0289b6835
Merge the trunk changes in. Breaks socket.ssl for now.
Thomas Wouters <thomas@python.org>
parents:
42084
diff
changeset
|
343 callLst[:] = [] |
|
27f0289b6835
Merge the trunk changes in. Breaks socket.ssl for now.
Thomas Wouters <thomas@python.org>
parents:
42084
diff
changeset
|
344 oct(testme) |
|
27f0289b6835
Merge the trunk changes in. Breaks socket.ssl for now.
Thomas Wouters <thomas@python.org>
parents:
42084
diff
changeset
|
345 self.assertCallStack([('__index__', (testme,))]) |
|
27f0289b6835
Merge the trunk changes in. Breaks socket.ssl for now.
Thomas Wouters <thomas@python.org>
parents:
42084
diff
changeset
|
346 callLst[:] = [] |
|
27f0289b6835
Merge the trunk changes in. Breaks socket.ssl for now.
Thomas Wouters <thomas@python.org>
parents:
42084
diff
changeset
|
347 hex(testme) |
|
27f0289b6835
Merge the trunk changes in. Breaks socket.ssl for now.
Thomas Wouters <thomas@python.org>
parents:
42084
diff
changeset
|
348 self.assertCallStack([('__index__', (testme,))]) |
|
14037
91f847a783d2
Apply SF patch #101029: call __getitem__ with a proper slice object if there
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
349 |
|
42954
27f0289b6835
Merge the trunk changes in. Breaks socket.ssl for now.
Thomas Wouters <thomas@python.org>
parents:
42084
diff
changeset
|
350 |
|
27f0289b6835
Merge the trunk changes in. Breaks socket.ssl for now.
Thomas Wouters <thomas@python.org>
parents:
42084
diff
changeset
|
351 def testMisc(self): |
|
27f0289b6835
Merge the trunk changes in. Breaks socket.ssl for now.
Thomas Wouters <thomas@python.org>
parents:
42084
diff
changeset
|
352 testme = AllTests() |
|
14037
91f847a783d2
Apply SF patch #101029: call __getitem__ with a proper slice object if there
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
353 |
|
42954
27f0289b6835
Merge the trunk changes in. Breaks socket.ssl for now.
Thomas Wouters <thomas@python.org>
parents:
42084
diff
changeset
|
354 callLst[:] = [] |
|
27f0289b6835
Merge the trunk changes in. Breaks socket.ssl for now.
Thomas Wouters <thomas@python.org>
parents:
42084
diff
changeset
|
355 hash(testme) |
|
27f0289b6835
Merge the trunk changes in. Breaks socket.ssl for now.
Thomas Wouters <thomas@python.org>
parents:
42084
diff
changeset
|
356 self.assertCallStack([('__hash__', (testme,))]) |
|
14037
91f847a783d2
Apply SF patch #101029: call __getitem__ with a proper slice object if there
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
357 |
|
42954
27f0289b6835
Merge the trunk changes in. Breaks socket.ssl for now.
Thomas Wouters <thomas@python.org>
parents:
42084
diff
changeset
|
358 callLst[:] = [] |
|
27f0289b6835
Merge the trunk changes in. Breaks socket.ssl for now.
Thomas Wouters <thomas@python.org>
parents:
42084
diff
changeset
|
359 repr(testme) |
|
27f0289b6835
Merge the trunk changes in. Breaks socket.ssl for now.
Thomas Wouters <thomas@python.org>
parents:
42084
diff
changeset
|
360 self.assertCallStack([('__repr__', (testme,))]) |
|
27f0289b6835
Merge the trunk changes in. Breaks socket.ssl for now.
Thomas Wouters <thomas@python.org>
parents:
42084
diff
changeset
|
361 |
|
27f0289b6835
Merge the trunk changes in. Breaks socket.ssl for now.
Thomas Wouters <thomas@python.org>
parents:
42084
diff
changeset
|
362 callLst[:] = [] |
|
27f0289b6835
Merge the trunk changes in. Breaks socket.ssl for now.
Thomas Wouters <thomas@python.org>
parents:
42084
diff
changeset
|
363 str(testme) |
|
27f0289b6835
Merge the trunk changes in. Breaks socket.ssl for now.
Thomas Wouters <thomas@python.org>
parents:
42084
diff
changeset
|
364 self.assertCallStack([('__str__', (testme,))]) |
|
14037
91f847a783d2
Apply SF patch #101029: call __getitem__ with a proper slice object if there
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
365 |
|
42954
27f0289b6835
Merge the trunk changes in. Breaks socket.ssl for now.
Thomas Wouters <thomas@python.org>
parents:
42084
diff
changeset
|
366 callLst[:] = [] |
|
27f0289b6835
Merge the trunk changes in. Breaks socket.ssl for now.
Thomas Wouters <thomas@python.org>
parents:
42084
diff
changeset
|
367 testme == 1 |
|
27f0289b6835
Merge the trunk changes in. Breaks socket.ssl for now.
Thomas Wouters <thomas@python.org>
parents:
42084
diff
changeset
|
368 self.assertCallStack([('__eq__', (testme, 1))]) |
|
14037
91f847a783d2
Apply SF patch #101029: call __getitem__ with a proper slice object if there
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
369 |
|
42954
27f0289b6835
Merge the trunk changes in. Breaks socket.ssl for now.
Thomas Wouters <thomas@python.org>
parents:
42084
diff
changeset
|
370 callLst[:] = [] |
|
27f0289b6835
Merge the trunk changes in. Breaks socket.ssl for now.
Thomas Wouters <thomas@python.org>
parents:
42084
diff
changeset
|
371 testme < 1 |
|
27f0289b6835
Merge the trunk changes in. Breaks socket.ssl for now.
Thomas Wouters <thomas@python.org>
parents:
42084
diff
changeset
|
372 self.assertCallStack([('__lt__', (testme, 1))]) |
|
27f0289b6835
Merge the trunk changes in. Breaks socket.ssl for now.
Thomas Wouters <thomas@python.org>
parents:
42084
diff
changeset
|
373 |
|
27f0289b6835
Merge the trunk changes in. Breaks socket.ssl for now.
Thomas Wouters <thomas@python.org>
parents:
42084
diff
changeset
|
374 callLst[:] = [] |
|
27f0289b6835
Merge the trunk changes in. Breaks socket.ssl for now.
Thomas Wouters <thomas@python.org>
parents:
42084
diff
changeset
|
375 testme > 1 |
|
27f0289b6835
Merge the trunk changes in. Breaks socket.ssl for now.
Thomas Wouters <thomas@python.org>
parents:
42084
diff
changeset
|
376 self.assertCallStack([('__gt__', (testme, 1))]) |
|
14037
91f847a783d2
Apply SF patch #101029: call __getitem__ with a proper slice object if there
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
377 |
|
42954
27f0289b6835
Merge the trunk changes in. Breaks socket.ssl for now.
Thomas Wouters <thomas@python.org>
parents:
42084
diff
changeset
|
378 callLst[:] = [] |
|
27f0289b6835
Merge the trunk changes in. Breaks socket.ssl for now.
Thomas Wouters <thomas@python.org>
parents:
42084
diff
changeset
|
379 testme != 1 |
|
27f0289b6835
Merge the trunk changes in. Breaks socket.ssl for now.
Thomas Wouters <thomas@python.org>
parents:
42084
diff
changeset
|
380 self.assertCallStack([('__ne__', (testme, 1))]) |
|
14037
91f847a783d2
Apply SF patch #101029: call __getitem__ with a proper slice object if there
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
381 |
|
42954
27f0289b6835
Merge the trunk changes in. Breaks socket.ssl for now.
Thomas Wouters <thomas@python.org>
parents:
42084
diff
changeset
|
382 callLst[:] = [] |
|
27f0289b6835
Merge the trunk changes in. Breaks socket.ssl for now.
Thomas Wouters <thomas@python.org>
parents:
42084
diff
changeset
|
383 1 == testme |
|
27f0289b6835
Merge the trunk changes in. Breaks socket.ssl for now.
Thomas Wouters <thomas@python.org>
parents:
42084
diff
changeset
|
384 self.assertCallStack([('__eq__', (1, testme))]) |
|
14037
91f847a783d2
Apply SF patch #101029: call __getitem__ with a proper slice object if there
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
385 |
|
42954
27f0289b6835
Merge the trunk changes in. Breaks socket.ssl for now.
Thomas Wouters <thomas@python.org>
parents:
42084
diff
changeset
|
386 callLst[:] = [] |
|
27f0289b6835
Merge the trunk changes in. Breaks socket.ssl for now.
Thomas Wouters <thomas@python.org>
parents:
42084
diff
changeset
|
387 1 < testme |
|
27f0289b6835
Merge the trunk changes in. Breaks socket.ssl for now.
Thomas Wouters <thomas@python.org>
parents:
42084
diff
changeset
|
388 self.assertCallStack([('__gt__', (1, testme))]) |
|
14037
91f847a783d2
Apply SF patch #101029: call __getitem__ with a proper slice object if there
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
389 |
|
42954
27f0289b6835
Merge the trunk changes in. Breaks socket.ssl for now.
Thomas Wouters <thomas@python.org>
parents:
42084
diff
changeset
|
390 callLst[:] = [] |
|
27f0289b6835
Merge the trunk changes in. Breaks socket.ssl for now.
Thomas Wouters <thomas@python.org>
parents:
42084
diff
changeset
|
391 1 > testme |
|
27f0289b6835
Merge the trunk changes in. Breaks socket.ssl for now.
Thomas Wouters <thomas@python.org>
parents:
42084
diff
changeset
|
392 self.assertCallStack([('__lt__', (1, testme))]) |
|
14037
91f847a783d2
Apply SF patch #101029: call __getitem__ with a proper slice object if there
Thomas Wouters <thomas@python.org>
parents:
diff
changeset
|
393 |
|
42954
27f0289b6835
Merge the trunk changes in. Breaks socket.ssl for now.
Thomas Wouters <thomas@python.org>
parents:
42084
diff
changeset
|
394 callLst[:] = [] |
|
27f0289b6835
Merge the trunk changes in. Breaks socket.ssl for now.
Thomas Wouters <thomas@python.org>
parents:
42084
diff
changeset
|
395 1 != testme |
|
27f0289b6835
Merge the trunk changes in. Breaks socket.ssl for now.
Thomas Wouters <thomas@python.org>
parents:
42084
diff
changeset
|
396 self.assertCallStack([('__ne__', (1, testme))]) |
|
16005
ced8041eb4ea
Add test that ensures hash() of objects defining __cmp__ or __eq__ but
Guido van Rossum <guido@python.org>
parents:
15305
diff
changeset
|
397 |
|
ced8041eb4ea
Add test that ensures hash() of objects defining __cmp__ or __eq__ but
Guido van Rossum <guido@python.org>
parents:
15305
diff
changeset
|
398 |
|
42954
27f0289b6835
Merge the trunk changes in. Breaks socket.ssl for now.
Thomas Wouters <thomas@python.org>
parents:
42084
diff
changeset
|
399 def testGetSetAndDel(self): |
|
27f0289b6835
Merge the trunk changes in. Breaks socket.ssl for now.
Thomas Wouters <thomas@python.org>
parents:
42084
diff
changeset
|
400 # Interfering tests |
|
27f0289b6835
Merge the trunk changes in. Breaks socket.ssl for now.
Thomas Wouters <thomas@python.org>
parents:
42084
diff
changeset
|
401 class ExtraTests(AllTests): |
|
27f0289b6835
Merge the trunk changes in. Breaks socket.ssl for now.
Thomas Wouters <thomas@python.org>
parents:
42084
diff
changeset
|
402 @trackCall |
|
27f0289b6835
Merge the trunk changes in. Breaks socket.ssl for now.
Thomas Wouters <thomas@python.org>
parents:
42084
diff
changeset
|
403 def __getattr__(self, *args): |
|
27f0289b6835
Merge the trunk changes in. Breaks socket.ssl for now.
Thomas Wouters <thomas@python.org>
parents:
42084
diff
changeset
|
404 return "SomeVal" |
|
27f0289b6835
Merge the trunk changes in. Breaks socket.ssl for now.
Thomas Wouters <thomas@python.org>
parents:
42084
diff
changeset
|
405 |
|
27f0289b6835
Merge the trunk changes in. Breaks socket.ssl for now.
Thomas Wouters <thomas@python.org>
parents:
42084
diff
changeset
|
406 @trackCall |
|
27f0289b6835
Merge the trunk changes in. Breaks socket.ssl for now.
Thomas Wouters <thomas@python.org>
parents:
42084
diff
changeset
|
407 def __setattr__(self, *args): |
|
27f0289b6835
Merge the trunk changes in. Breaks socket.ssl for now.
Thomas Wouters <thomas@python.org>
parents:
42084
diff
changeset
|
408 pass |
|
27f0289b6835
Merge the trunk changes in. Breaks socket.ssl for now.
Thomas Wouters <thomas@python.org>
parents:
42084
diff
changeset
|
409 |
|
27f0289b6835
Merge the trunk changes in. Breaks socket.ssl for now.
Thomas Wouters <thomas@python.org>
parents:
42084
diff
changeset
|
410 @trackCall |
|
27f0289b6835
Merge the trunk changes in. Breaks socket.ssl for now.
Thomas Wouters <thomas@python.org>
parents:
42084
diff
changeset
|
411 def __delattr__(self, *args): |
|
27f0289b6835
Merge the trunk changes in. Breaks socket.ssl for now.
Thomas Wouters <thomas@python.org>
parents:
42084
diff
changeset
|
412 pass |
|
32759
d1777f51923b
Check the type of values returned by __int__, __float__, __long__,
Neil Schemenauer <nascheme@enme.ucalgary.ca>
parents:
30723
diff
changeset
|
413 |
|
42954
27f0289b6835
Merge the trunk changes in. Breaks socket.ssl for now.
Thomas Wouters <thomas@python.org>
parents:
42084
diff
changeset
|
414 testme = ExtraTests() |
|
27f0289b6835
Merge the trunk changes in. Breaks socket.ssl for now.
Thomas Wouters <thomas@python.org>
parents:
42084
diff
changeset
|
415 |
|
27f0289b6835
Merge the trunk changes in. Breaks socket.ssl for now.
Thomas Wouters <thomas@python.org>
parents:
42084
diff
changeset
|
416 callLst[:] = [] |
|
27f0289b6835
Merge the trunk changes in. Breaks socket.ssl for now.
Thomas Wouters <thomas@python.org>
parents:
42084
diff
changeset
|
417 testme.spam |
|
27f0289b6835
Merge the trunk changes in. Breaks socket.ssl for now.
Thomas Wouters <thomas@python.org>
parents:
42084
diff
changeset
|
418 self.assertCallStack([('__getattr__', (testme, "spam"))]) |
|
32759
d1777f51923b
Check the type of values returned by __int__, __float__, __long__,
Neil Schemenauer <nascheme@enme.ucalgary.ca>
parents:
30723
diff
changeset
|
419 |
|
42954
27f0289b6835
Merge the trunk changes in. Breaks socket.ssl for now.
Thomas Wouters <thomas@python.org>
parents:
42084
diff
changeset
|
420 callLst[:] = [] |
|
27f0289b6835
Merge the trunk changes in. Breaks socket.ssl for now.
Thomas Wouters <thomas@python.org>
parents:
42084
diff
changeset
|
421 testme.eggs = "spam, spam, spam and ham" |
|
27f0289b6835
Merge the trunk changes in. Breaks socket.ssl for now.
Thomas Wouters <thomas@python.org>
parents:
42084
diff
changeset
|
422 self.assertCallStack([('__setattr__', (testme, "eggs", |
|
27f0289b6835
Merge the trunk changes in. Breaks socket.ssl for now.
Thomas Wouters <thomas@python.org>
parents:
42084
diff
changeset
|
423 "spam, spam, spam and ham"))]) |
|
32759
d1777f51923b
Check the type of values returned by __int__, __float__, __long__,
Neil Schemenauer <nascheme@enme.ucalgary.ca>
parents:
30723
diff
changeset
|
424 |
|
42954
27f0289b6835
Merge the trunk changes in. Breaks socket.ssl for now.
Thomas Wouters <thomas@python.org>
parents:
42084
diff
changeset
|
425 callLst[:] = [] |
|
27f0289b6835
Merge the trunk changes in. Breaks socket.ssl for now.
Thomas Wouters <thomas@python.org>
parents:
42084
diff
changeset
|
426 del testme.cardinal |
|
27f0289b6835
Merge the trunk changes in. Breaks socket.ssl for now.
Thomas Wouters <thomas@python.org>
parents:
42084
diff
changeset
|
427 self.assertCallStack([('__delattr__', (testme, "cardinal"))]) |
|
27f0289b6835
Merge the trunk changes in. Breaks socket.ssl for now.
Thomas Wouters <thomas@python.org>
parents:
42084
diff
changeset
|
428 |
|
27f0289b6835
Merge the trunk changes in. Breaks socket.ssl for now.
Thomas Wouters <thomas@python.org>
parents:
42084
diff
changeset
|
429 def testDel(self): |
|
27f0289b6835
Merge the trunk changes in. Breaks socket.ssl for now.
Thomas Wouters <thomas@python.org>
parents:
42084
diff
changeset
|
430 x = [] |
|
16005
ced8041eb4ea
Add test that ensures hash() of objects defining __cmp__ or __eq__ but
Guido van Rossum <guido@python.org>
parents:
15305
diff
changeset
|
431 |
|
42954
27f0289b6835
Merge the trunk changes in. Breaks socket.ssl for now.
Thomas Wouters <thomas@python.org>
parents:
42084
diff
changeset
|
432 class DelTest: |
|
27f0289b6835
Merge the trunk changes in. Breaks socket.ssl for now.
Thomas Wouters <thomas@python.org>
parents:
42084
diff
changeset
|
433 def __del__(self): |
|
27f0289b6835
Merge the trunk changes in. Breaks socket.ssl for now.
Thomas Wouters <thomas@python.org>
parents:
42084
diff
changeset
|
434 x.append("crab people, crab people") |
|
27f0289b6835
Merge the trunk changes in. Breaks socket.ssl for now.
Thomas Wouters <thomas@python.org>
parents:
42084
diff
changeset
|
435 testme = DelTest() |
|
27f0289b6835
Merge the trunk changes in. Breaks socket.ssl for now.
Thomas Wouters <thomas@python.org>
parents:
42084
diff
changeset
|
436 del testme |
|
27f0289b6835
Merge the trunk changes in. Breaks socket.ssl for now.
Thomas Wouters <thomas@python.org>
parents:
42084
diff
changeset
|
437 import gc |
|
27f0289b6835
Merge the trunk changes in. Breaks socket.ssl for now.
Thomas Wouters <thomas@python.org>
parents:
42084
diff
changeset
|
438 gc.collect() |
|
66310
9fe76c26ea9f
#9424: Replace deprecated assert* methods in the Python test suite.
Ezio Melotti <ezio.melotti@gmail.com>
parents:
49518
diff
changeset
|
439 self.assertEqual(["crab people, crab people"], x) |
|
16005
ced8041eb4ea
Add test that ensures hash() of objects defining __cmp__ or __eq__ but
Guido van Rossum <guido@python.org>
parents:
15305
diff
changeset
|
440 |
|
42954
27f0289b6835
Merge the trunk changes in. Breaks socket.ssl for now.
Thomas Wouters <thomas@python.org>
parents:
42084
diff
changeset
|
441 def testBadTypeReturned(self): |
|
27f0289b6835
Merge the trunk changes in. Breaks socket.ssl for now.
Thomas Wouters <thomas@python.org>
parents:
42084
diff
changeset
|
442 # return values of some method are type-checked |
|
27f0289b6835
Merge the trunk changes in. Breaks socket.ssl for now.
Thomas Wouters <thomas@python.org>
parents:
42084
diff
changeset
|
443 class BadTypeClass: |
|
27f0289b6835
Merge the trunk changes in. Breaks socket.ssl for now.
Thomas Wouters <thomas@python.org>
parents:
42084
diff
changeset
|
444 def __int__(self): |
|
27f0289b6835
Merge the trunk changes in. Breaks socket.ssl for now.
Thomas Wouters <thomas@python.org>
parents:
42084
diff
changeset
|
445 return None |
|
27f0289b6835
Merge the trunk changes in. Breaks socket.ssl for now.
Thomas Wouters <thomas@python.org>
parents:
42084
diff
changeset
|
446 __float__ = __int__ |
|
27f0289b6835
Merge the trunk changes in. Breaks socket.ssl for now.
Thomas Wouters <thomas@python.org>
parents:
42084
diff
changeset
|
447 __str__ = __int__ |
|
27f0289b6835
Merge the trunk changes in. Breaks socket.ssl for now.
Thomas Wouters <thomas@python.org>
parents:
42084
diff
changeset
|
448 __repr__ = __int__ |
|
27f0289b6835
Merge the trunk changes in. Breaks socket.ssl for now.
Thomas Wouters <thomas@python.org>
parents:
42084
diff
changeset
|
449 __oct__ = __int__ |
|
27f0289b6835
Merge the trunk changes in. Breaks socket.ssl for now.
Thomas Wouters <thomas@python.org>
parents:
42084
diff
changeset
|
450 __hex__ = __int__ |
|
16005
ced8041eb4ea
Add test that ensures hash() of objects defining __cmp__ or __eq__ but
Guido van Rossum <guido@python.org>
parents:
15305
diff
changeset
|
451 |
|
42954
27f0289b6835
Merge the trunk changes in. Breaks socket.ssl for now.
Thomas Wouters <thomas@python.org>
parents:
42084
diff
changeset
|
452 for f in [int, float, str, repr, oct, hex]: |
|
27f0289b6835
Merge the trunk changes in. Breaks socket.ssl for now.
Thomas Wouters <thomas@python.org>
parents:
42084
diff
changeset
|
453 self.assertRaises(TypeError, f, BadTypeClass()) |
|
23839
c8815bd01ff5
Fix for SF bug 532646. This is a little simpler than what Neal
Guido van Rossum <guido@python.org>
parents:
21351
diff
changeset
|
454 |
|
42954
27f0289b6835
Merge the trunk changes in. Breaks socket.ssl for now.
Thomas Wouters <thomas@python.org>
parents:
42084
diff
changeset
|
455 def testHashStuff(self): |
|
27f0289b6835
Merge the trunk changes in. Breaks socket.ssl for now.
Thomas Wouters <thomas@python.org>
parents:
42084
diff
changeset
|
456 # Test correct errors from hash() on objects with comparisons but |
|
27f0289b6835
Merge the trunk changes in. Breaks socket.ssl for now.
Thomas Wouters <thomas@python.org>
parents:
42084
diff
changeset
|
457 # no __hash__ |
|
27f0289b6835
Merge the trunk changes in. Breaks socket.ssl for now.
Thomas Wouters <thomas@python.org>
parents:
42084
diff
changeset
|
458 |
|
27f0289b6835
Merge the trunk changes in. Breaks socket.ssl for now.
Thomas Wouters <thomas@python.org>
parents:
42084
diff
changeset
|
459 class C0: |
|
27f0289b6835
Merge the trunk changes in. Breaks socket.ssl for now.
Thomas Wouters <thomas@python.org>
parents:
42084
diff
changeset
|
460 pass |
|
23839
c8815bd01ff5
Fix for SF bug 532646. This is a little simpler than what Neal
Guido van Rossum <guido@python.org>
parents:
21351
diff
changeset
|
461 |
|
42954
27f0289b6835
Merge the trunk changes in. Breaks socket.ssl for now.
Thomas Wouters <thomas@python.org>
parents:
42084
diff
changeset
|
462 hash(C0()) # This should work; the next two should raise TypeError |
|
27f0289b6835
Merge the trunk changes in. Breaks socket.ssl for now.
Thomas Wouters <thomas@python.org>
parents:
42084
diff
changeset
|
463 |
|
27f0289b6835
Merge the trunk changes in. Breaks socket.ssl for now.
Thomas Wouters <thomas@python.org>
parents:
42084
diff
changeset
|
464 class C2: |
|
27f0289b6835
Merge the trunk changes in. Breaks socket.ssl for now.
Thomas Wouters <thomas@python.org>
parents:
42084
diff
changeset
|
465 def __eq__(self, other): return 1 |
|
27f0289b6835
Merge the trunk changes in. Breaks socket.ssl for now.
Thomas Wouters <thomas@python.org>
parents:
42084
diff
changeset
|
466 |
|
27f0289b6835
Merge the trunk changes in. Breaks socket.ssl for now.
Thomas Wouters <thomas@python.org>
parents:
42084
diff
changeset
|
467 self.assertRaises(TypeError, hash, C2()) |
|
25942
3db772d45f98
Added test for this fix to classobject.c:
Guido van Rossum <guido@python.org>
parents:
24442
diff
changeset
|
468 |
|
3db772d45f98
Added test for this fix to classobject.c:
Guido van Rossum <guido@python.org>
parents:
24442
diff
changeset
|
469 |
|
42954
27f0289b6835
Merge the trunk changes in. Breaks socket.ssl for now.
Thomas Wouters <thomas@python.org>
parents:
42084
diff
changeset
|
470 def testSFBug532646(self): |
|
27f0289b6835
Merge the trunk changes in. Breaks socket.ssl for now.
Thomas Wouters <thomas@python.org>
parents:
42084
diff
changeset
|
471 # Test for SF bug 532646 |
|
25942
3db772d45f98
Added test for this fix to classobject.c:
Guido van Rossum <guido@python.org>
parents:
24442
diff
changeset
|
472 |
|
42954
27f0289b6835
Merge the trunk changes in. Breaks socket.ssl for now.
Thomas Wouters <thomas@python.org>
parents:
42084
diff
changeset
|
473 class A: |
|
27f0289b6835
Merge the trunk changes in. Breaks socket.ssl for now.
Thomas Wouters <thomas@python.org>
parents:
42084
diff
changeset
|
474 pass |
|
27f0289b6835
Merge the trunk changes in. Breaks socket.ssl for now.
Thomas Wouters <thomas@python.org>
parents:
42084
diff
changeset
|
475 A.__call__ = A() |
|
27f0289b6835
Merge the trunk changes in. Breaks socket.ssl for now.
Thomas Wouters <thomas@python.org>
parents:
42084
diff
changeset
|
476 a = A() |
|
27f0289b6835
Merge the trunk changes in. Breaks socket.ssl for now.
Thomas Wouters <thomas@python.org>
parents:
42084
diff
changeset
|
477 |
|
27f0289b6835
Merge the trunk changes in. Breaks socket.ssl for now.
Thomas Wouters <thomas@python.org>
parents:
42084
diff
changeset
|
478 try: |
|
27f0289b6835
Merge the trunk changes in. Breaks socket.ssl for now.
Thomas Wouters <thomas@python.org>
parents:
42084
diff
changeset
|
479 a() # This should not segfault |
|
27f0289b6835
Merge the trunk changes in. Breaks socket.ssl for now.
Thomas Wouters <thomas@python.org>
parents:
42084
diff
changeset
|
480 except RuntimeError: |
|
27f0289b6835
Merge the trunk changes in. Breaks socket.ssl for now.
Thomas Wouters <thomas@python.org>
parents:
42084
diff
changeset
|
481 pass |
|
27f0289b6835
Merge the trunk changes in. Breaks socket.ssl for now.
Thomas Wouters <thomas@python.org>
parents:
42084
diff
changeset
|
482 else: |
|
27f0289b6835
Merge the trunk changes in. Breaks socket.ssl for now.
Thomas Wouters <thomas@python.org>
parents:
42084
diff
changeset
|
483 self.fail("Failed to raise RuntimeError") |
|
25942
3db772d45f98
Added test for this fix to classobject.c:
Guido van Rossum <guido@python.org>
parents:
24442
diff
changeset
|
484 |
|
42954
27f0289b6835
Merge the trunk changes in. Breaks socket.ssl for now.
Thomas Wouters <thomas@python.org>
parents:
42084
diff
changeset
|
485 def testForExceptionsRaisedInInstanceGetattr2(self): |
|
27f0289b6835
Merge the trunk changes in. Breaks socket.ssl for now.
Thomas Wouters <thomas@python.org>
parents:
42084
diff
changeset
|
486 # Tests for exceptions raised in instance_getattr2(). |
|
27f0289b6835
Merge the trunk changes in. Breaks socket.ssl for now.
Thomas Wouters <thomas@python.org>
parents:
42084
diff
changeset
|
487 |
|
27f0289b6835
Merge the trunk changes in. Breaks socket.ssl for now.
Thomas Wouters <thomas@python.org>
parents:
42084
diff
changeset
|
488 def booh(self): |
|
27f0289b6835
Merge the trunk changes in. Breaks socket.ssl for now.
Thomas Wouters <thomas@python.org>
parents:
42084
diff
changeset
|
489 raise AttributeError("booh") |
|
25942
3db772d45f98
Added test for this fix to classobject.c:
Guido van Rossum <guido@python.org>
parents:
24442
diff
changeset
|
490 |
|
42954
27f0289b6835
Merge the trunk changes in. Breaks socket.ssl for now.
Thomas Wouters <thomas@python.org>
parents:
42084
diff
changeset
|
491 class A: |
|
27f0289b6835
Merge the trunk changes in. Breaks socket.ssl for now.
Thomas Wouters <thomas@python.org>
parents:
42084
diff
changeset
|
492 a = property(booh) |
|
27f0289b6835
Merge the trunk changes in. Breaks socket.ssl for now.
Thomas Wouters <thomas@python.org>
parents:
42084
diff
changeset
|
493 try: |
|
27f0289b6835
Merge the trunk changes in. Breaks socket.ssl for now.
Thomas Wouters <thomas@python.org>
parents:
42084
diff
changeset
|
494 A().a # Raised AttributeError: A instance has no attribute 'a' |
|
27f0289b6835
Merge the trunk changes in. Breaks socket.ssl for now.
Thomas Wouters <thomas@python.org>
parents:
42084
diff
changeset
|
495 except AttributeError as x: |
|
27f0289b6835
Merge the trunk changes in. Breaks socket.ssl for now.
Thomas Wouters <thomas@python.org>
parents:
42084
diff
changeset
|
496 if str(x) != "booh": |
|
27f0289b6835
Merge the trunk changes in. Breaks socket.ssl for now.
Thomas Wouters <thomas@python.org>
parents:
42084
diff
changeset
|
497 self.fail("attribute error for A().a got masked: %s" % x) |
|
38673
a19c20c5e5c7
Merge the rest of the trunk.
Thomas Wouters <thomas@python.org>
parents:
37743
diff
changeset
|
498 |
|
42954
27f0289b6835
Merge the trunk changes in. Breaks socket.ssl for now.
Thomas Wouters <thomas@python.org>
parents:
42084
diff
changeset
|
499 class E: |
|
27f0289b6835
Merge the trunk changes in. Breaks socket.ssl for now.
Thomas Wouters <thomas@python.org>
parents:
42084
diff
changeset
|
500 __eq__ = property(booh) |
|
27f0289b6835
Merge the trunk changes in. Breaks socket.ssl for now.
Thomas Wouters <thomas@python.org>
parents:
42084
diff
changeset
|
501 E() == E() # In debug mode, caused a C-level assert() to fail |
|
38673
a19c20c5e5c7
Merge the rest of the trunk.
Thomas Wouters <thomas@python.org>
parents:
37743
diff
changeset
|
502 |
|
42954
27f0289b6835
Merge the trunk changes in. Breaks socket.ssl for now.
Thomas Wouters <thomas@python.org>
parents:
42084
diff
changeset
|
503 class I: |
|
27f0289b6835
Merge the trunk changes in. Breaks socket.ssl for now.
Thomas Wouters <thomas@python.org>
parents:
42084
diff
changeset
|
504 __init__ = property(booh) |
|
27f0289b6835
Merge the trunk changes in. Breaks socket.ssl for now.
Thomas Wouters <thomas@python.org>
parents:
42084
diff
changeset
|
505 try: |
|
27f0289b6835
Merge the trunk changes in. Breaks socket.ssl for now.
Thomas Wouters <thomas@python.org>
parents:
42084
diff
changeset
|
506 # In debug mode, printed XXX undetected error and |
|
27f0289b6835
Merge the trunk changes in. Breaks socket.ssl for now.
Thomas Wouters <thomas@python.org>
parents:
42084
diff
changeset
|
507 # raises AttributeError |
|
27f0289b6835
Merge the trunk changes in. Breaks socket.ssl for now.
Thomas Wouters <thomas@python.org>
parents:
42084
diff
changeset
|
508 I() |
|
27f0289b6835
Merge the trunk changes in. Breaks socket.ssl for now.
Thomas Wouters <thomas@python.org>
parents:
42084
diff
changeset
|
509 except AttributeError as x: |
|
27f0289b6835
Merge the trunk changes in. Breaks socket.ssl for now.
Thomas Wouters <thomas@python.org>
parents:
42084
diff
changeset
|
510 pass |
|
27f0289b6835
Merge the trunk changes in. Breaks socket.ssl for now.
Thomas Wouters <thomas@python.org>
parents:
42084
diff
changeset
|
511 else: |
|
27f0289b6835
Merge the trunk changes in. Breaks socket.ssl for now.
Thomas Wouters <thomas@python.org>
parents:
42084
diff
changeset
|
512 self.fail("attribute error for I.__init__ got masked") |
|
38673
a19c20c5e5c7
Merge the rest of the trunk.
Thomas Wouters <thomas@python.org>
parents:
37743
diff
changeset
|
513 |
|
42954
27f0289b6835
Merge the trunk changes in. Breaks socket.ssl for now.
Thomas Wouters <thomas@python.org>
parents:
42084
diff
changeset
|
514 def testHashComparisonOfMethods(self): |
|
27f0289b6835
Merge the trunk changes in. Breaks socket.ssl for now.
Thomas Wouters <thomas@python.org>
parents:
42084
diff
changeset
|
515 # Test comparison and hash of methods |
|
27f0289b6835
Merge the trunk changes in. Breaks socket.ssl for now.
Thomas Wouters <thomas@python.org>
parents:
42084
diff
changeset
|
516 class A: |
|
27f0289b6835
Merge the trunk changes in. Breaks socket.ssl for now.
Thomas Wouters <thomas@python.org>
parents:
42084
diff
changeset
|
517 def __init__(self, x): |
|
27f0289b6835
Merge the trunk changes in. Breaks socket.ssl for now.
Thomas Wouters <thomas@python.org>
parents:
42084
diff
changeset
|
518 self.x = x |
|
27f0289b6835
Merge the trunk changes in. Breaks socket.ssl for now.
Thomas Wouters <thomas@python.org>
parents:
42084
diff
changeset
|
519 def f(self): |
|
27f0289b6835
Merge the trunk changes in. Breaks socket.ssl for now.
Thomas Wouters <thomas@python.org>
parents:
42084
diff
changeset
|
520 pass |
|
27f0289b6835
Merge the trunk changes in. Breaks socket.ssl for now.
Thomas Wouters <thomas@python.org>
parents:
42084
diff
changeset
|
521 def g(self): |
|
27f0289b6835
Merge the trunk changes in. Breaks socket.ssl for now.
Thomas Wouters <thomas@python.org>
parents:
42084
diff
changeset
|
522 pass |
|
27f0289b6835
Merge the trunk changes in. Breaks socket.ssl for now.
Thomas Wouters <thomas@python.org>
parents:
42084
diff
changeset
|
523 def __eq__(self, other): |
|
27f0289b6835
Merge the trunk changes in. Breaks socket.ssl for now.
Thomas Wouters <thomas@python.org>
parents:
42084
diff
changeset
|
524 return self.x == other.x |
|
27f0289b6835
Merge the trunk changes in. Breaks socket.ssl for now.
Thomas Wouters <thomas@python.org>
parents:
42084
diff
changeset
|
525 def __hash__(self): |
|
27f0289b6835
Merge the trunk changes in. Breaks socket.ssl for now.
Thomas Wouters <thomas@python.org>
parents:
42084
diff
changeset
|
526 return self.x |
|
27f0289b6835
Merge the trunk changes in. Breaks socket.ssl for now.
Thomas Wouters <thomas@python.org>
parents:
42084
diff
changeset
|
527 class B(A): |
|
27f0289b6835
Merge the trunk changes in. Breaks socket.ssl for now.
Thomas Wouters <thomas@python.org>
parents:
42084
diff
changeset
|
528 pass |
|
38673
a19c20c5e5c7
Merge the rest of the trunk.
Thomas Wouters <thomas@python.org>
parents:
37743
diff
changeset
|
529 |
|
42954
27f0289b6835
Merge the trunk changes in. Breaks socket.ssl for now.
Thomas Wouters <thomas@python.org>
parents:
42084
diff
changeset
|
530 a1 = A(1) |
|
27f0289b6835
Merge the trunk changes in. Breaks socket.ssl for now.
Thomas Wouters <thomas@python.org>
parents:
42084
diff
changeset
|
531 a2 = A(2) |
|
66310
9fe76c26ea9f
#9424: Replace deprecated assert* methods in the Python test suite.
Ezio Melotti <ezio.melotti@gmail.com>
parents:
49518
diff
changeset
|
532 self.assertEqual(a1.f, a1.f) |
|
9fe76c26ea9f
#9424: Replace deprecated assert* methods in the Python test suite.
Ezio Melotti <ezio.melotti@gmail.com>
parents:
49518
diff
changeset
|
533 self.assertNotEqual(a1.f, a2.f) |
|
9fe76c26ea9f
#9424: Replace deprecated assert* methods in the Python test suite.
Ezio Melotti <ezio.melotti@gmail.com>
parents:
49518
diff
changeset
|
534 self.assertNotEqual(a1.f, a1.g) |
|
9fe76c26ea9f
#9424: Replace deprecated assert* methods in the Python test suite.
Ezio Melotti <ezio.melotti@gmail.com>
parents:
49518
diff
changeset
|
535 self.assertEqual(a1.f, A(1).f) |
|
9fe76c26ea9f
#9424: Replace deprecated assert* methods in the Python test suite.
Ezio Melotti <ezio.melotti@gmail.com>
parents:
49518
diff
changeset
|
536 self.assertEqual(hash(a1.f), hash(a1.f)) |
|
9fe76c26ea9f
#9424: Replace deprecated assert* methods in the Python test suite.
Ezio Melotti <ezio.melotti@gmail.com>
parents:
49518
diff
changeset
|
537 self.assertEqual(hash(a1.f), hash(A(1).f)) |
|
38673
a19c20c5e5c7
Merge the rest of the trunk.
Thomas Wouters <thomas@python.org>
parents:
37743
diff
changeset
|
538 |
|
66310
9fe76c26ea9f
#9424: Replace deprecated assert* methods in the Python test suite.
Ezio Melotti <ezio.melotti@gmail.com>
parents:
49518
diff
changeset
|
539 self.assertNotEqual(A.f, a1.f) |
|
9fe76c26ea9f
#9424: Replace deprecated assert* methods in the Python test suite.
Ezio Melotti <ezio.melotti@gmail.com>
parents:
49518
diff
changeset
|
540 self.assertNotEqual(A.f, A.g) |
|
9fe76c26ea9f
#9424: Replace deprecated assert* methods in the Python test suite.
Ezio Melotti <ezio.melotti@gmail.com>
parents:
49518
diff
changeset
|
541 self.assertEqual(B.f, A.f) |
|
9fe76c26ea9f
#9424: Replace deprecated assert* methods in the Python test suite.
Ezio Melotti <ezio.melotti@gmail.com>
parents:
49518
diff
changeset
|
542 self.assertEqual(hash(B.f), hash(A.f)) |
|
42954
27f0289b6835
Merge the trunk changes in. Breaks socket.ssl for now.
Thomas Wouters <thomas@python.org>
parents:
42084
diff
changeset
|
543 |
|
27f0289b6835
Merge the trunk changes in. Breaks socket.ssl for now.
Thomas Wouters <thomas@python.org>
parents:
42084
diff
changeset
|
544 # the following triggers a SystemError in 2.4 |
|
44021
ff5df1fc0fcc
Patch from Georg Brandl and me for #1493
Christian Heimes <christian@cheimes.de>
parents:
43100
diff
changeset
|
545 a = A(hash(A.f)^(-1)) |
|
42954
27f0289b6835
Merge the trunk changes in. Breaks socket.ssl for now.
Thomas Wouters <thomas@python.org>
parents:
42084
diff
changeset
|
546 hash(a.f) |
|
27f0289b6835
Merge the trunk changes in. Breaks socket.ssl for now.
Thomas Wouters <thomas@python.org>
parents:
42084
diff
changeset
|
547 |
|
27f0289b6835
Merge the trunk changes in. Breaks socket.ssl for now.
Thomas Wouters <thomas@python.org>
parents:
42084
diff
changeset
|
548 def test_main(): |
|
47201
9c930a32cebb
#2621 rename test.test_support to test.support
Benjamin Peterson <benjamin@python.org>
parents:
45471
diff
changeset
|
549 support.run_unittest(ClassTests) |
|
42954
27f0289b6835
Merge the trunk changes in. Breaks socket.ssl for now.
Thomas Wouters <thomas@python.org>
parents:
42084
diff
changeset
|
550 |
|
27f0289b6835
Merge the trunk changes in. Breaks socket.ssl for now.
Thomas Wouters <thomas@python.org>
parents:
42084
diff
changeset
|
551 if __name__=='__main__': |
|
27f0289b6835
Merge the trunk changes in. Breaks socket.ssl for now.
Thomas Wouters <thomas@python.org>
parents:
42084
diff
changeset
|
552 test_main() |
