From e276753b458ef7c4c05469324173a455c0e2db46 Mon Sep 17 00:00:00 2001 From: Paul Sokolovsky Date: Fri, 2 May 2014 02:30:28 +0300 Subject: [PATCH] tests: Add testcases for catching user Exception subclasses. --- tests/basics/subclass-native3.py | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/tests/basics/subclass-native3.py b/tests/basics/subclass-native3.py index dd6a94a614..bd99ab0d6a 100644 --- a/tests/basics/subclass-native3.py +++ b/tests/basics/subclass-native3.py @@ -5,3 +5,18 @@ e = MyExc(100, "Some error") print(e) print(repr(e)) print(e.args) + +try: + raise MyExc("Some error") +except MyExc as e: + print("Caught exception:", repr(e)) + +try: + raise MyExc("Some error2") +except Exception as e: + print("Caught exception:", repr(e)) + +try: + raise MyExc("Some error2") +except: + print("Caught user exception")