From: Stefan Behnel Date: Sun, 8 Dec 2013 11:49:46 +0000 (+0100) Subject: add test for empty try-finally X-Git-Tag: 0.20b1~133 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=1ae99fe10961ee12b365fbf28833a8568b6b73b2;p=platform%2Fupstream%2Fpython-cython.git add test for empty try-finally --- diff --git a/tests/run/tryfinally.pyx b/tests/run/tryfinally.pyx index d8cbaa7..a9d8cdf 100644 --- a/tests/run/tryfinally.pyx +++ b/tests/run/tryfinally.pyx @@ -1,6 +1,8 @@ # mode: run # tag: tryfinally +cimport cython + def finally_except(): """ >>> try: @@ -128,3 +130,34 @@ def try_break(): break except: break + + +def empty_try(): + """ + >>> empty_try() + 1 + """ + try: + pass + finally: + return 1 + + +def empty_try_in_except_raise(raise_in_finally): + """ + >>> empty_try_in_except_raise(False) + Traceback (most recent call last): + ValueError: HUHU + >>> empty_try_in_except_raise(True) + Traceback (most recent call last): + TypeError: OLA + """ + try: + raise ValueError("HUHU") + except ValueError: + try: + pass + finally: + if raise_in_finally: + raise TypeError('OLA') + raise