Show More
@@ -229,43 +229,44 b' except Exception:' | |||||
229 | #---------------------------------------------------------------------------- |
|
229 | #---------------------------------------------------------------------------- | |
230 |
|
230 | |||
231 | # module testing (minimal) |
|
231 | # module testing (minimal) | |
232 | def test_handlers(): |
|
232 | if sys.version_info > (3,): | |
233 | def spam(c, d_e): |
|
233 | def test_handlers(): | |
234 |
( |
|
234 | def spam(c, d_e): | |
235 | x = c + d |
|
235 | (d, e) = d_e | |
236 |
|
|
236 | x = c + d | |
237 | foo(x, y) |
|
237 | y = c * d | |
238 |
|
238 | foo(x, y) | ||
239 | def foo(a, b, bar=1): |
|
239 | ||
240 |
|
|
240 | def foo(a, b, bar=1): | |
241 |
|
241 | eggs(a, b + bar) | ||
242 | def eggs(f, g, z=globals()): |
|
242 | ||
243 | h = f + g |
|
243 | def eggs(f, g, z=globals()): | |
244 |
|
|
244 | h = f + g | |
245 | return h / i |
|
245 | i = f - g | |
246 |
|
246 | return h / i | ||
247 | buff = io.StringIO() |
|
247 | ||
248 |
|
248 | buff = io.StringIO() | ||
249 | buff.write(u'') |
|
249 | ||
250 |
buff.write( |
|
250 | buff.write('') | |
251 | try: |
|
251 | buff.write('*** Before ***') | |
252 | buff.write(spam(1, (2, 3))) |
|
252 | try: | |
253 | except: |
|
253 | buff.write(spam(1, (2, 3))) | |
254 | traceback.print_exc(file=buff) |
|
254 | except: | |
255 |
|
255 | traceback.print_exc(file=buff) | ||
256 | handler = ColorTB(ostream=buff) |
|
256 | ||
257 | buff.write(u'*** ColorTB ***') |
|
257 | handler = ColorTB(ostream=buff) | |
258 | try: |
|
258 | buff.write('*** ColorTB ***') | |
259 | buff.write(spam(1, (2, 3))) |
|
259 | try: | |
260 | except: |
|
260 | buff.write(spam(1, (2, 3))) | |
261 | handler(*sys.exc_info()) |
|
261 | except: | |
262 | buff.write(u'') |
|
262 | handler(*sys.exc_info()) | |
263 |
|
263 | buff.write('') | ||
264 | handler = VerboseTB(ostream=buff) |
|
264 | ||
265 | buff.write(u'*** VerboseTB ***') |
|
265 | handler = VerboseTB(ostream=buff) | |
266 | try: |
|
266 | buff.write('*** VerboseTB ***') | |
267 | buff.write(spam(1, (2, 3))) |
|
267 | try: | |
268 | except: |
|
268 | buff.write(spam(1, (2, 3))) | |
269 | handler(*sys.exc_info()) |
|
269 | except: | |
270 | buff.write(u'') |
|
270 | handler(*sys.exc_info()) | |
|
271 | buff.write('') | |||
271 |
|
272 |
General Comments 0
You need to be logged in to leave comments.
Login now