Mercurial > cpython-lru_cache-weakref
annotate Lib/test/inspect_fodder2.py @ 58925:eecf1bef052d 2.6
Merged revisions 78207 via svnmerge from
svn+ssh://pythondev@svn.python.org/python/trunk
........
r78207 | ezio.melotti | 2010-02-17 01:26:09 +0200 (Wed, 17 Feb 2010) | 1 line
#7930: fix stripid
........
| author | Ezio Melotti <ezio.melotti@gmail.com> |
|---|---|
| date | Tue, 16 Feb 2010 23:29:44 +0000 |
| parents | 14ec9cfd9760 |
| children | 4cdf21a0dbbc |
| rev | line source |
|---|---|
|
34151
de4701fc176f
Patch #736962: port test_inspect to unittest. As part of this, move out
Johannes Gijsbers <jlg@dds.nl>
parents:
diff
changeset
|
1 # line 1 |
|
de4701fc176f
Patch #736962: port test_inspect to unittest. As part of this, move out
Johannes Gijsbers <jlg@dds.nl>
parents:
diff
changeset
|
2 def wrap(foo=None): |
|
34358
b1a84233d855
Whitespace normalization.
Tim Peters <tim.peters@gmail.com>
parents:
34152
diff
changeset
|
3 def wrapper(func): |
|
b1a84233d855
Whitespace normalization.
Tim Peters <tim.peters@gmail.com>
parents:
34152
diff
changeset
|
4 return func |
|
b1a84233d855
Whitespace normalization.
Tim Peters <tim.peters@gmail.com>
parents:
34152
diff
changeset
|
5 return wrapper |
|
34151
de4701fc176f
Patch #736962: port test_inspect to unittest. As part of this, move out
Johannes Gijsbers <jlg@dds.nl>
parents:
diff
changeset
|
6 |
|
de4701fc176f
Patch #736962: port test_inspect to unittest. As part of this, move out
Johannes Gijsbers <jlg@dds.nl>
parents:
diff
changeset
|
7 # line 7 |
|
de4701fc176f
Patch #736962: port test_inspect to unittest. As part of this, move out
Johannes Gijsbers <jlg@dds.nl>
parents:
diff
changeset
|
8 def replace(func): |
|
34358
b1a84233d855
Whitespace normalization.
Tim Peters <tim.peters@gmail.com>
parents:
34152
diff
changeset
|
9 def insteadfunc(): |
|
b1a84233d855
Whitespace normalization.
Tim Peters <tim.peters@gmail.com>
parents:
34152
diff
changeset
|
10 print 'hello' |
|
b1a84233d855
Whitespace normalization.
Tim Peters <tim.peters@gmail.com>
parents:
34152
diff
changeset
|
11 return insteadfunc |
|
34151
de4701fc176f
Patch #736962: port test_inspect to unittest. As part of this, move out
Johannes Gijsbers <jlg@dds.nl>
parents:
diff
changeset
|
12 |
|
de4701fc176f
Patch #736962: port test_inspect to unittest. As part of this, move out
Johannes Gijsbers <jlg@dds.nl>
parents:
diff
changeset
|
13 # line 13 |
|
de4701fc176f
Patch #736962: port test_inspect to unittest. As part of this, move out
Johannes Gijsbers <jlg@dds.nl>
parents:
diff
changeset
|
14 @wrap() |
|
de4701fc176f
Patch #736962: port test_inspect to unittest. As part of this, move out
Johannes Gijsbers <jlg@dds.nl>
parents:
diff
changeset
|
15 @wrap(wrap) |
|
de4701fc176f
Patch #736962: port test_inspect to unittest. As part of this, move out
Johannes Gijsbers <jlg@dds.nl>
parents:
diff
changeset
|
16 def wrapped(): |
|
34358
b1a84233d855
Whitespace normalization.
Tim Peters <tim.peters@gmail.com>
parents:
34152
diff
changeset
|
17 pass |
|
34151
de4701fc176f
Patch #736962: port test_inspect to unittest. As part of this, move out
Johannes Gijsbers <jlg@dds.nl>
parents:
diff
changeset
|
18 |
|
de4701fc176f
Patch #736962: port test_inspect to unittest. As part of this, move out
Johannes Gijsbers <jlg@dds.nl>
parents:
diff
changeset
|
19 # line 19 |
|
de4701fc176f
Patch #736962: port test_inspect to unittest. As part of this, move out
Johannes Gijsbers <jlg@dds.nl>
parents:
diff
changeset
|
20 @replace |
|
de4701fc176f
Patch #736962: port test_inspect to unittest. As part of this, move out
Johannes Gijsbers <jlg@dds.nl>
parents:
diff
changeset
|
21 def gone(): |
|
34358
b1a84233d855
Whitespace normalization.
Tim Peters <tim.peters@gmail.com>
parents:
34152
diff
changeset
|
22 pass |
|
34152
bbdaacc44f6f
Patch #1011890: fix inspect.getsource breaking with line-continuation &
Johannes Gijsbers <jlg@dds.nl>
parents:
34151
diff
changeset
|
23 |
|
bbdaacc44f6f
Patch #1011890: fix inspect.getsource breaking with line-continuation &
Johannes Gijsbers <jlg@dds.nl>
parents:
34151
diff
changeset
|
24 # line 24 |
|
bbdaacc44f6f
Patch #1011890: fix inspect.getsource breaking with line-continuation &
Johannes Gijsbers <jlg@dds.nl>
parents:
34151
diff
changeset
|
25 oll = lambda m: m |
|
bbdaacc44f6f
Patch #1011890: fix inspect.getsource breaking with line-continuation &
Johannes Gijsbers <jlg@dds.nl>
parents:
34151
diff
changeset
|
26 |
|
bbdaacc44f6f
Patch #1011890: fix inspect.getsource breaking with line-continuation &
Johannes Gijsbers <jlg@dds.nl>
parents:
34151
diff
changeset
|
27 # line 27 |
|
bbdaacc44f6f
Patch #1011890: fix inspect.getsource breaking with line-continuation &
Johannes Gijsbers <jlg@dds.nl>
parents:
34151
diff
changeset
|
28 tll = lambda g: g and \ |
|
bbdaacc44f6f
Patch #1011890: fix inspect.getsource breaking with line-continuation &
Johannes Gijsbers <jlg@dds.nl>
parents:
34151
diff
changeset
|
29 g and \ |
|
bbdaacc44f6f
Patch #1011890: fix inspect.getsource breaking with line-continuation &
Johannes Gijsbers <jlg@dds.nl>
parents:
34151
diff
changeset
|
30 g |
|
bbdaacc44f6f
Patch #1011890: fix inspect.getsource breaking with line-continuation &
Johannes Gijsbers <jlg@dds.nl>
parents:
34151
diff
changeset
|
31 |
|
bbdaacc44f6f
Patch #1011890: fix inspect.getsource breaking with line-continuation &
Johannes Gijsbers <jlg@dds.nl>
parents:
34151
diff
changeset
|
32 # line 32 |
|
bbdaacc44f6f
Patch #1011890: fix inspect.getsource breaking with line-continuation &
Johannes Gijsbers <jlg@dds.nl>
parents:
34151
diff
changeset
|
33 tlli = lambda d: d and \ |
|
bbdaacc44f6f
Patch #1011890: fix inspect.getsource breaking with line-continuation &
Johannes Gijsbers <jlg@dds.nl>
parents:
34151
diff
changeset
|
34 d |
|
bbdaacc44f6f
Patch #1011890: fix inspect.getsource breaking with line-continuation &
Johannes Gijsbers <jlg@dds.nl>
parents:
34151
diff
changeset
|
35 |
|
bbdaacc44f6f
Patch #1011890: fix inspect.getsource breaking with line-continuation &
Johannes Gijsbers <jlg@dds.nl>
parents:
34151
diff
changeset
|
36 # line 36 |
|
bbdaacc44f6f
Patch #1011890: fix inspect.getsource breaking with line-continuation &
Johannes Gijsbers <jlg@dds.nl>
parents:
34151
diff
changeset
|
37 def onelinefunc(): pass |
|
bbdaacc44f6f
Patch #1011890: fix inspect.getsource breaking with line-continuation &
Johannes Gijsbers <jlg@dds.nl>
parents:
34151
diff
changeset
|
38 |
|
bbdaacc44f6f
Patch #1011890: fix inspect.getsource breaking with line-continuation &
Johannes Gijsbers <jlg@dds.nl>
parents:
34151
diff
changeset
|
39 # line 39 |
|
bbdaacc44f6f
Patch #1011890: fix inspect.getsource breaking with line-continuation &
Johannes Gijsbers <jlg@dds.nl>
parents:
34151
diff
changeset
|
40 def manyargs(arg1, arg2, |
|
bbdaacc44f6f
Patch #1011890: fix inspect.getsource breaking with line-continuation &
Johannes Gijsbers <jlg@dds.nl>
parents:
34151
diff
changeset
|
41 arg3, arg4): pass |
|
bbdaacc44f6f
Patch #1011890: fix inspect.getsource breaking with line-continuation &
Johannes Gijsbers <jlg@dds.nl>
parents:
34151
diff
changeset
|
42 |
|
bbdaacc44f6f
Patch #1011890: fix inspect.getsource breaking with line-continuation &
Johannes Gijsbers <jlg@dds.nl>
parents:
34151
diff
changeset
|
43 # line 43 |
|
bbdaacc44f6f
Patch #1011890: fix inspect.getsource breaking with line-continuation &
Johannes Gijsbers <jlg@dds.nl>
parents:
34151
diff
changeset
|
44 def twolinefunc(m): return m and \ |
|
bbdaacc44f6f
Patch #1011890: fix inspect.getsource breaking with line-continuation &
Johannes Gijsbers <jlg@dds.nl>
parents:
34151
diff
changeset
|
45 m |
|
bbdaacc44f6f
Patch #1011890: fix inspect.getsource breaking with line-continuation &
Johannes Gijsbers <jlg@dds.nl>
parents:
34151
diff
changeset
|
46 |
|
bbdaacc44f6f
Patch #1011890: fix inspect.getsource breaking with line-continuation &
Johannes Gijsbers <jlg@dds.nl>
parents:
34151
diff
changeset
|
47 # line 47 |
|
bbdaacc44f6f
Patch #1011890: fix inspect.getsource breaking with line-continuation &
Johannes Gijsbers <jlg@dds.nl>
parents:
34151
diff
changeset
|
48 a = [None, |
|
bbdaacc44f6f
Patch #1011890: fix inspect.getsource breaking with line-continuation &
Johannes Gijsbers <jlg@dds.nl>
parents:
34151
diff
changeset
|
49 lambda x: x, |
|
bbdaacc44f6f
Patch #1011890: fix inspect.getsource breaking with line-continuation &
Johannes Gijsbers <jlg@dds.nl>
parents:
34151
diff
changeset
|
50 None] |
|
bbdaacc44f6f
Patch #1011890: fix inspect.getsource breaking with line-continuation &
Johannes Gijsbers <jlg@dds.nl>
parents:
34151
diff
changeset
|
51 |
|
bbdaacc44f6f
Patch #1011890: fix inspect.getsource breaking with line-continuation &
Johannes Gijsbers <jlg@dds.nl>
parents:
34151
diff
changeset
|
52 # line 52 |
|
bbdaacc44f6f
Patch #1011890: fix inspect.getsource breaking with line-continuation &
Johannes Gijsbers <jlg@dds.nl>
parents:
34151
diff
changeset
|
53 def setfunc(func): |
|
bbdaacc44f6f
Patch #1011890: fix inspect.getsource breaking with line-continuation &
Johannes Gijsbers <jlg@dds.nl>
parents:
34151
diff
changeset
|
54 globals()["anonymous"] = func |
|
bbdaacc44f6f
Patch #1011890: fix inspect.getsource breaking with line-continuation &
Johannes Gijsbers <jlg@dds.nl>
parents:
34151
diff
changeset
|
55 setfunc(lambda x, y: x*y) |
|
34740
3bb759498767
Patch #1159931/bug #1143895: inspect.getsource failed when functions,
Johannes Gijsbers <jlg@dds.nl>
parents:
34358
diff
changeset
|
56 |
|
3bb759498767
Patch #1159931/bug #1143895: inspect.getsource failed when functions,
Johannes Gijsbers <jlg@dds.nl>
parents:
34358
diff
changeset
|
57 # line 57 |
|
3bb759498767
Patch #1159931/bug #1143895: inspect.getsource failed when functions,
Johannes Gijsbers <jlg@dds.nl>
parents:
34358
diff
changeset
|
58 def with_comment(): # hello |
|
3bb759498767
Patch #1159931/bug #1143895: inspect.getsource failed when functions,
Johannes Gijsbers <jlg@dds.nl>
parents:
34358
diff
changeset
|
59 world |
|
3bb759498767
Patch #1159931/bug #1143895: inspect.getsource failed when functions,
Johannes Gijsbers <jlg@dds.nl>
parents:
34358
diff
changeset
|
60 |
|
3bb759498767
Patch #1159931/bug #1143895: inspect.getsource failed when functions,
Johannes Gijsbers <jlg@dds.nl>
parents:
34358
diff
changeset
|
61 # line 61 |
|
3bb759498767
Patch #1159931/bug #1143895: inspect.getsource failed when functions,
Johannes Gijsbers <jlg@dds.nl>
parents:
34358
diff
changeset
|
62 multiline_sig = [ |
|
3bb759498767
Patch #1159931/bug #1143895: inspect.getsource failed when functions,
Johannes Gijsbers <jlg@dds.nl>
parents:
34358
diff
changeset
|
63 lambda (x, |
|
3bb759498767
Patch #1159931/bug #1143895: inspect.getsource failed when functions,
Johannes Gijsbers <jlg@dds.nl>
parents:
34358
diff
changeset
|
64 y): x+y, |
|
3bb759498767
Patch #1159931/bug #1143895: inspect.getsource failed when functions,
Johannes Gijsbers <jlg@dds.nl>
parents:
34358
diff
changeset
|
65 None, |
|
3bb759498767
Patch #1159931/bug #1143895: inspect.getsource failed when functions,
Johannes Gijsbers <jlg@dds.nl>
parents:
34358
diff
changeset
|
66 ] |
|
35640
1e7b755194a4
some more fixes and tests for inspect.getsource(), triggered by crashes
Armin Rigo <arigo@tunes.org>
parents:
34740
diff
changeset
|
67 |
|
1e7b755194a4
some more fixes and tests for inspect.getsource(), triggered by crashes
Armin Rigo <arigo@tunes.org>
parents:
34740
diff
changeset
|
68 # line 68 |
|
1e7b755194a4
some more fixes and tests for inspect.getsource(), triggered by crashes
Armin Rigo <arigo@tunes.org>
parents:
34740
diff
changeset
|
69 def func69(): |
|
1e7b755194a4
some more fixes and tests for inspect.getsource(), triggered by crashes
Armin Rigo <arigo@tunes.org>
parents:
34740
diff
changeset
|
70 class cls70: |
|
1e7b755194a4
some more fixes and tests for inspect.getsource(), triggered by crashes
Armin Rigo <arigo@tunes.org>
parents:
34740
diff
changeset
|
71 def func71(): |
|
1e7b755194a4
some more fixes and tests for inspect.getsource(), triggered by crashes
Armin Rigo <arigo@tunes.org>
parents:
34740
diff
changeset
|
72 pass |
|
1e7b755194a4
some more fixes and tests for inspect.getsource(), triggered by crashes
Armin Rigo <arigo@tunes.org>
parents:
34740
diff
changeset
|
73 return cls70 |
|
1e7b755194a4
some more fixes and tests for inspect.getsource(), triggered by crashes
Armin Rigo <arigo@tunes.org>
parents:
34740
diff
changeset
|
74 extra74 = 74 |
|
1e7b755194a4
some more fixes and tests for inspect.getsource(), triggered by crashes
Armin Rigo <arigo@tunes.org>
parents:
34740
diff
changeset
|
75 |
|
1e7b755194a4
some more fixes and tests for inspect.getsource(), triggered by crashes
Armin Rigo <arigo@tunes.org>
parents:
34740
diff
changeset
|
76 # line 76 |
|
1e7b755194a4
some more fixes and tests for inspect.getsource(), triggered by crashes
Armin Rigo <arigo@tunes.org>
parents:
34740
diff
changeset
|
77 def func77(): pass |
|
1e7b755194a4
some more fixes and tests for inspect.getsource(), triggered by crashes
Armin Rigo <arigo@tunes.org>
parents:
34740
diff
changeset
|
78 (extra78, stuff78) = 'xy' |
|
1e7b755194a4
some more fixes and tests for inspect.getsource(), triggered by crashes
Armin Rigo <arigo@tunes.org>
parents:
34740
diff
changeset
|
79 extra79 = 'stop' |
|
1e7b755194a4
some more fixes and tests for inspect.getsource(), triggered by crashes
Armin Rigo <arigo@tunes.org>
parents:
34740
diff
changeset
|
80 |
|
1e7b755194a4
some more fixes and tests for inspect.getsource(), triggered by crashes
Armin Rigo <arigo@tunes.org>
parents:
34740
diff
changeset
|
81 # line 81 |
|
1e7b755194a4
some more fixes and tests for inspect.getsource(), triggered by crashes
Armin Rigo <arigo@tunes.org>
parents:
34740
diff
changeset
|
82 class cls82: |
|
1e7b755194a4
some more fixes and tests for inspect.getsource(), triggered by crashes
Armin Rigo <arigo@tunes.org>
parents:
34740
diff
changeset
|
83 def func83(): pass |
|
1e7b755194a4
some more fixes and tests for inspect.getsource(), triggered by crashes
Armin Rigo <arigo@tunes.org>
parents:
34740
diff
changeset
|
84 (extra84, stuff84) = 'xy' |
|
1e7b755194a4
some more fixes and tests for inspect.getsource(), triggered by crashes
Armin Rigo <arigo@tunes.org>
parents:
34740
diff
changeset
|
85 extra85 = 'stop' |
|
1e7b755194a4
some more fixes and tests for inspect.getsource(), triggered by crashes
Armin Rigo <arigo@tunes.org>
parents:
34740
diff
changeset
|
86 |
|
1e7b755194a4
some more fixes and tests for inspect.getsource(), triggered by crashes
Armin Rigo <arigo@tunes.org>
parents:
34740
diff
changeset
|
87 # line 87 |
|
1e7b755194a4
some more fixes and tests for inspect.getsource(), triggered by crashes
Armin Rigo <arigo@tunes.org>
parents:
34740
diff
changeset
|
88 def func88(): |
|
1e7b755194a4
some more fixes and tests for inspect.getsource(), triggered by crashes
Armin Rigo <arigo@tunes.org>
parents:
34740
diff
changeset
|
89 # comment |
|
1e7b755194a4
some more fixes and tests for inspect.getsource(), triggered by crashes
Armin Rigo <arigo@tunes.org>
parents:
34740
diff
changeset
|
90 return 90 |
|
39495
14ec9cfd9760
Make tabnanny recognize IndentationErrors raised by tokenize.
Georg Brandl <georg@python.org>
parents:
35640
diff
changeset
|
91 |
|
14ec9cfd9760
Make tabnanny recognize IndentationErrors raised by tokenize.
Georg Brandl <georg@python.org>
parents:
35640
diff
changeset
|
92 # line 92 |
|
14ec9cfd9760
Make tabnanny recognize IndentationErrors raised by tokenize.
Georg Brandl <georg@python.org>
parents:
35640
diff
changeset
|
93 def f(): |
|
14ec9cfd9760
Make tabnanny recognize IndentationErrors raised by tokenize.
Georg Brandl <georg@python.org>
parents:
35640
diff
changeset
|
94 class X: |
|
14ec9cfd9760
Make tabnanny recognize IndentationErrors raised by tokenize.
Georg Brandl <georg@python.org>
parents:
35640
diff
changeset
|
95 def g(): |
|
14ec9cfd9760
Make tabnanny recognize IndentationErrors raised by tokenize.
Georg Brandl <georg@python.org>
parents:
35640
diff
changeset
|
96 "doc" |
|
14ec9cfd9760
Make tabnanny recognize IndentationErrors raised by tokenize.
Georg Brandl <georg@python.org>
parents:
35640
diff
changeset
|
97 return 42 |
|
14ec9cfd9760
Make tabnanny recognize IndentationErrors raised by tokenize.
Georg Brandl <georg@python.org>
parents:
35640
diff
changeset
|
98 return X |
|
14ec9cfd9760
Make tabnanny recognize IndentationErrors raised by tokenize.
Georg Brandl <georg@python.org>
parents:
35640
diff
changeset
|
99 method_in_dynamic_class = f().g.im_func |
