Left: | ||
Right: |
LEFT | RIGHT |
---|---|
1 # Copyright 2007 Google, Inc. All Rights Reserved. | 1 # Copyright 2007 Google, Inc. All Rights Reserved. |
2 # Licensed to PSF under a Contributor Agreement. | 2 # Licensed to PSF under a Contributor Agreement. |
3 | 3 |
4 """Tests for the raise statement.""" | 4 """Tests for the raise statement.""" |
5 | 5 |
6 from test import support | 6 from test import support |
7 import sys | 7 import sys |
8 import types | 8 import types |
9 import unittest | 9 import unittest |
10 | 10 |
(...skipping 260 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
271 def __exit__(self, t, v, tb): | 271 def __exit__(self, t, v, tb): |
272 xyzzy | 272 xyzzy |
273 try: | 273 try: |
274 with ContextManager(): | 274 with ContextManager(): |
275 1/0 | 275 1/0 |
276 except NameError as e: | 276 except NameError as e: |
277 self.failUnless(isinstance(e.__context__, ZeroDivisionError)) | 277 self.failUnless(isinstance(e.__context__, ZeroDivisionError)) |
278 else: | 278 else: |
279 self.fail("No exception raised") | 279 self.fail("No exception raised") |
280 | 280 |
281 def test_trivial_cycle(self): | 281 def test_cycle_broken(self): |
Benjamin
2008/07/13 21:15:39
Please rename this to test_cycle_broken.
| |
282 # Self-cycles (when re-raising a caught exception) are broken | 282 # Self-cycles (when re-raising a caught exception) are broken |
283 try: | 283 try: |
284 try: | 284 try: |
285 1/0 | 285 1/0 |
286 except ZeroDivisionError as e: | 286 except ZeroDivisionError as e: |
287 raise e | 287 raise e |
288 except ZeroDivisionError as e: | 288 except ZeroDivisionError as e: |
289 self.failUnless(e.__context__ is None, e.__context__) | 289 self.failUnless(e.__context__ is None, e.__context__) |
290 | 290 |
291 def test_nontrivial_cycle(self): | 291 def test_reraise_cycle_broken(self): |
Benjamin
2008/07/13 21:15:39
Please rename this to test_reraise_cycle_broken.
| |
292 # Non-trivial context cycles (through re-raising a previous exception) | 292 # Non-trivial context cycles (through re-raising a previous exception) |
293 # are broken too. | 293 # are broken too. |
294 try: | 294 try: |
295 try: | 295 try: |
296 xyzzy | 296 xyzzy |
297 except NameError as a: | 297 except NameError as a: |
298 try: | 298 try: |
299 1/0 | 299 1/0 |
300 except ZeroDivisionError: | 300 except ZeroDivisionError: |
301 raise a | 301 raise a |
(...skipping 17 matching lines...) Expand all Loading... | |
319 pass | 319 pass |
320 else: | 320 else: |
321 self.fail("No exception raised") | 321 self.fail("No exception raised") |
322 | 322 |
323 | 323 |
324 def test_main(): | 324 def test_main(): |
325 support.run_unittest(__name__) | 325 support.run_unittest(__name__) |
326 | 326 |
327 if __name__ == "__main__": | 327 if __name__ == "__main__": |
328 unittest.main() | 328 unittest.main() |
LEFT | RIGHT |