Show More
@@ -8,7 +8,8 b' def div0():' | |||||
8 | x/y |
|
8 | x/y | |
9 |
|
9 | |||
10 | def sysexit(stat, mode): |
|
10 | def sysexit(stat, mode): | |
11 |
raise SystemExit(stat, |
|
11 | raise SystemExit(stat, f"Mode = {mode}") | |
|
12 | ||||
12 |
|
13 | |||
13 | def bar(mode): |
|
14 | def bar(mode): | |
14 | "bar" |
|
15 | "bar" |
@@ -40,49 +40,48 b' def test_reset():' | |||||
40 |
|
40 | |||
41 | def doctest_tb_plain(): |
|
41 | def doctest_tb_plain(): | |
42 | """ |
|
42 | """ | |
43 | In [18]: xmode plain |
|
43 | In [18]: xmode plain | |
44 | Exception reporting mode: Plain |
|
44 | Exception reporting mode: Plain | |
45 |
|
45 | |||
46 | In [19]: run simpleerr.py |
|
46 | In [19]: run simpleerr.py | |
47 | Traceback (most recent call last): |
|
47 | Traceback (most recent call last): | |
48 |
...line |
|
48 | ...line ..., in <module> | |
49 | bar(mode) |
|
49 | bar(mode) | |
50 |
...line |
|
50 | ...line ..., in bar | |
51 | div0() |
|
51 | div0() | |
52 |
...line |
|
52 | ...line ..., in div0 | |
53 | x/y |
|
53 | x/y | |
54 | ZeroDivisionError: ... |
|
54 | ZeroDivisionError: ... | |
55 | """ |
|
55 | """ | |
56 |
|
56 | |||
57 |
|
57 | |||
58 | def doctest_tb_context(): |
|
58 | def doctest_tb_context(): | |
59 | """ |
|
59 | """ | |
60 | In [3]: xmode context |
|
60 | In [3]: xmode context | |
61 | Exception reporting mode: Context |
|
61 | Exception reporting mode: Context | |
62 |
|
62 | |||
63 | In [4]: run simpleerr.py |
|
63 | In [4]: run simpleerr.py | |
64 | --------------------------------------------------------------------------- |
|
64 | --------------------------------------------------------------------------- | |
65 | ZeroDivisionError Traceback (most recent call last) |
|
65 | ZeroDivisionError Traceback (most recent call last) | |
66 | <BLANKLINE> |
|
66 | <BLANKLINE> | |
67 | ... in <module> |
|
67 | ... in <module> | |
68 |
|
|
68 | 30 except IndexError: | |
69 |
|
|
69 | 31 mode = 'div' | |
70 |
---> 3 |
|
70 | ---> 33 bar(mode) | |
71 | <BLANKLINE> |
|
71 | <BLANKLINE> | |
72 | ... in bar(mode) |
|
72 | ... in bar(mode) | |
73 |
|
|
73 | 15 "bar" | |
74 |
|
|
74 | 16 if mode=='div': | |
75 |
---> 1 |
|
75 | ---> 17 div0() | |
76 |
|
|
76 | 18 elif mode=='exit': | |
77 |
|
|
77 | 19 try: | |
78 | <BLANKLINE> |
|
78 | <BLANKLINE> | |
79 | ... in div0() |
|
79 | ... in div0() | |
80 | 6 x = 1 |
|
80 | 6 x = 1 | |
81 | 7 y = 0 |
|
81 | 7 y = 0 | |
82 | ----> 8 x/y |
|
82 | ----> 8 x/y | |
83 | <BLANKLINE> |
|
83 | <BLANKLINE> | |
84 | ZeroDivisionError: ... |
|
84 | ZeroDivisionError: ...""" | |
85 | """ |
|
|||
86 |
|
85 | |||
87 |
|
86 | |||
88 | def doctest_tb_verbose(): |
|
87 | def doctest_tb_verbose(): | |
@@ -95,17 +94,17 b' def doctest_tb_verbose():' | |||||
95 | ZeroDivisionError Traceback (most recent call last) |
|
94 | ZeroDivisionError Traceback (most recent call last) | |
96 | <BLANKLINE> |
|
95 | <BLANKLINE> | |
97 | ... in <module> |
|
96 | ... in <module> | |
98 |
|
|
97 | 30 except IndexError: | |
99 |
3 |
|
98 | 31 mode = 'div' | |
100 |
---> 3 |
|
99 | ---> 33 bar(mode) | |
101 | mode = 'div' |
|
100 | mode = 'div' | |
102 | <BLANKLINE> |
|
101 | <BLANKLINE> | |
103 | ... in bar(mode='div') |
|
102 | ... in bar(mode='div') | |
104 |
1 |
|
103 | 15 "bar" | |
105 |
1 |
|
104 | 16 if mode=='div': | |
106 |
---> 1 |
|
105 | ---> 17 div0() | |
107 |
1 |
|
106 | 18 elif mode=='exit': | |
108 |
1 |
|
107 | 19 try: | |
109 | <BLANKLINE> |
|
108 | <BLANKLINE> | |
110 | ... in div0() |
|
109 | ... in div0() | |
111 | 6 x = 1 |
|
110 | 6 x = 1 | |
@@ -118,91 +117,100 b' def doctest_tb_verbose():' | |||||
118 | """ |
|
117 | """ | |
119 |
|
118 | |||
120 |
|
119 | |||
121 | # TODO : Marc 2021 βΒ this seem to fail due |
|
120 | def doctest_tb_sysexit(): | |
122 | # to upstream changes in CI for whatever reason. |
|
121 | """ | |
123 | # Commenting for now, to revive someday (maybe?) |
|
122 | In [17]: %xmode plain | |
124 | # nose won't work in 3.10 anyway and we'll have to disable iptest. |
|
123 | Exception reporting mode: Plain | |
125 | # thus this likely need to bemigrated to pytest. |
|
124 | ||
126 |
|
125 | In [18]: %run simpleerr.py exit | ||
127 |
|
126 | An exception has occurred, use %tb to see the full traceback. | ||
128 | # def doctest_tb_sysexit(): |
|
127 | SystemExit: (1, 'Mode = exit') | |
129 | # """ |
|
128 | ||
130 | # In [17]: %xmode plain |
|
129 | In [19]: %run simpleerr.py exit 2 | |
131 | # Exception reporting mode: Plain |
|
130 | An exception has occurred, use %tb to see the full traceback. | |
132 | # |
|
131 | SystemExit: (2, 'Mode = exit') | |
133 | # In [18]: %run simpleerr.py exit |
|
132 | ||
134 | # An exception has occurred, use %tb to see the full traceback. |
|
133 | In [20]: %tb | |
135 | # SystemExit: (1, 'Mode = exit') |
|
134 | Traceback (most recent call last): | |
136 | # |
|
135 | File ..., in execfile | |
137 | # In [19]: %run simpleerr.py exit 2 |
|
136 | exec(compiler(f.read(), fname, 'exec'), glob, loc) | |
138 | # An exception has occurred, use %tb to see the full traceback. |
|
137 | File ..., in <module> | |
139 | # SystemExit: (2, 'Mode = exit') |
|
138 | bar(mode) | |
140 | # |
|
139 | File ..., in bar | |
141 | # In [20]: %tb |
|
140 | sysexit(stat, mode) | |
142 | # Traceback (most recent call last): |
|
141 | File ..., in sysexit | |
143 | # File ... in <module> |
|
142 | raise SystemExit(stat, f"Mode = {mode}") | |
144 | # bar(mode) |
|
143 | SystemExit: (2, 'Mode = exit') | |
145 | # File ... line 22, in bar |
|
144 | ||
146 | # sysexit(stat, mode) |
|
145 | In [21]: %xmode context | |
147 | # File ... line 11, in sysexit |
|
146 | Exception reporting mode: Context | |
148 | # raise SystemExit(stat, 'Mode = %s' % mode) |
|
147 | ||
149 | # SystemExit: (2, 'Mode = exit') |
|
148 | In [22]: %tb | |
150 | # |
|
149 | --------------------------------------------------------------------------- | |
151 | # In [21]: %xmode context |
|
150 | SystemExit Traceback (most recent call last) | |
152 | # Exception reporting mode: Context |
|
151 | File ..., in execfile(fname, glob, loc, compiler) | |
153 | # |
|
152 | 70 with open(fname, 'rb') as f: | |
154 | # In [22]: %tb |
|
153 | 71 compiler = compiler or compile | |
155 | # --------------------------------------------------------------------------- |
|
154 | ---> 72 exec(compiler(f.read(), fname, 'exec'), glob, loc) | |
156 | # SystemExit Traceback (most recent call last) |
|
155 | ...<module> | |
157 | # <BLANKLINE> |
|
156 | 30 except IndexError: | |
158 | # ...<module> |
|
157 | 31 mode = 'div' | |
159 | # 29 except IndexError: |
|
158 | ---> 33 bar(mode) | |
160 | # 30 mode = 'div' |
|
159 | <BLANKLINE> | |
161 |
|
|
160 | ...bar(mode) | |
162 | # <BLANKLINE> |
|
161 | 21 except: | |
163 | # ...bar(mode) |
|
162 | 22 stat = 1 | |
164 | # 20 except: |
|
163 | ---> 23 sysexit(stat, mode) | |
165 | # 21 stat = 1 |
|
164 | 24 else: | |
166 | # ---> 22 sysexit(stat, mode) |
|
165 | 25 raise ValueError('Unknown mode') | |
167 | # 23 else: |
|
166 | <BLANKLINE> | |
168 | # 24 raise ValueError('Unknown mode') |
|
167 | ...sysexit(stat, mode) | |
169 | # <BLANKLINE> |
|
168 | 10 def sysexit(stat, mode): | |
170 | # ...sysexit(stat, mode) |
|
169 | ---> 11 raise SystemExit(stat, f"Mode = {mode}") | |
171 | # 10 def sysexit(stat, mode): |
|
170 | <BLANKLINE> | |
172 |
|
|
171 | SystemExit: (2, 'Mode = exit') | |
173 | # <BLANKLINE> |
|
172 | """ | |
174 | # SystemExit: (2, 'Mode = exit') |
|
173 | ||
175 | # |
|
174 | ||
176 | # In [23]: %xmode verbose |
|
175 | def doctest_tb_sysexit_verbose(): | |
177 | # Exception reporting mode: Verbose |
|
176 | """ | |
178 | # |
|
177 | In [18]: %run simpleerr.py exit | |
179 | # In [24]: %tb |
|
178 | An exception has occurred, use %tb to see the full traceback. | |
180 | # --------------------------------------------------------------------------- |
|
179 | SystemExit: (1, 'Mode = exit') | |
181 | # SystemExit Traceback (most recent call last) |
|
180 | ||
182 | # <BLANKLINE> |
|
181 | In [19]: %run simpleerr.py exit 2 | |
183 | # ... in <module> |
|
182 | An exception has occurred, use %tb to see the full traceback. | |
184 | # 29 except IndexError: |
|
183 | SystemExit: (2, 'Mode = exit') | |
185 | # 30 mode = 'div' |
|
184 | ||
186 | # ---> 32 bar(mode) |
|
185 | In [23]: %xmode verbose | |
187 | # mode = 'exit' |
|
186 | Exception reporting mode: Verbose | |
188 | # <BLANKLINE> |
|
187 | ||
189 | # ... in bar(mode='exit') |
|
188 | In [24]: %tb | |
190 | # 20 except: |
|
189 | --------------------------------------------------------------------------- | |
191 | # 21 stat = 1 |
|
190 | SystemExit Traceback (most recent call last) | |
192 | # ---> 22 sysexit(stat, mode) |
|
191 | <BLANKLINE> | |
193 | # mode = 'exit' |
|
192 | ... in <module> | |
194 | # stat = 2 |
|
193 | 30 except IndexError: | |
195 | # 23 else: |
|
194 | 31 mode = 'div' | |
196 | # 24 raise ValueError('Unknown mode') |
|
195 | ---> 33 bar(mode) | |
197 | # <BLANKLINE> |
|
196 | mode = 'exit' | |
198 | # ... in sysexit(stat=2, mode='exit') |
|
197 | <BLANKLINE> | |
199 | # 10 def sysexit(stat, mode): |
|
198 | ... in bar(mode='exit') | |
200 | # ---> 11 raise SystemExit(stat, 'Mode = %s' % mode) |
|
199 | ... except: | |
201 |
|
|
200 | ... stat = 1 | |
202 | # mode = 'exit' |
|
201 | ---> ... sysexit(stat, mode) | |
203 | # <BLANKLINE> |
|
202 | mode = 'exit' | |
204 | # SystemExit: (2, 'Mode = exit') |
|
203 | stat = 2 | |
205 | # """ |
|
204 | ... else: | |
|
205 | ... raise ValueError('Unknown mode') | |||
|
206 | <BLANKLINE> | |||
|
207 | ... in sysexit(stat=2, mode='exit') | |||
|
208 | 10 def sysexit(stat, mode): | |||
|
209 | ---> 11 raise SystemExit(stat, f"Mode = {mode}") | |||
|
210 | stat = 2 | |||
|
211 | <BLANKLINE> | |||
|
212 | SystemExit: (2, 'Mode = exit') | |||
|
213 | """ | |||
206 |
|
214 | |||
207 |
|
215 | |||
208 | def test_run_cell(): |
|
216 | def test_run_cell(): |
General Comments 0
You need to be logged in to leave comments.
Login now