File tree Expand file tree Collapse file tree 4 files changed +95
-2
lines changed
test_garlicsim/test_general_misc/test_exceptions Expand file tree Collapse file tree 4 files changed +95
-2
lines changed Original file line number Diff line number Diff line change @@ -14,7 +14,8 @@ def __init__(self, message=None):
1414 # to force an empty message.
1515
1616 if message is None :
17- if self .__doc__ and (type (self ) is not CuteException ):
17+ if self .__doc__ and \
18+ (type (self ) not in (CuteBaseException , CuteException )):
1819 message = self .__doc__ .strip ().split ('\n ' )[0 ]
1920 # Getting the first line of the documentation
2021 else :
@@ -32,7 +33,7 @@ def __init__(self, message=None):
3233 '''
3334
3435
35- class CuteException (Exception , CuteBaseException ):
36+ class CuteException (CuteBaseException , Exception ):
3637 '''Exception that uses its first docstring line in lieu of a message.'''
3738
3839
Original file line number Diff line number Diff line change 1+ # Copyright 2009-2011 Ram Rachum.
2+ # This program is distributed under the LGPL2.1 license.
3+
4+ '''Testing package for `garlicsim.general_misc.exceptions`.'''
Original file line number Diff line number Diff line change 1+ # Copyright 2009-2011 Ram Rachum.
2+ # This program is distributed under the LGPL2.1 license.
3+
4+ '''Testing package for `exceptions.CuteBaseException`.'''
5+
6+ from garlicsim .general_misc import cute_testing
7+
8+ from garlicsim .general_misc .exceptions import CuteBaseException , CuteException
9+
10+
11+ def test ():
12+
13+ try :
14+ raise CuteBaseException
15+ except BaseException , base_exception :
16+ assert base_exception .message == ''
17+ else :
18+ raise cute_testing .Failure
19+
20+ try :
21+ raise CuteBaseException ()
22+ except BaseException , base_exception :
23+ assert base_exception .message == ''
24+ else :
25+ raise cute_testing .Failure
26+
27+
28+ class MyBaseException (CuteBaseException ):
29+ '''My hovercraft is full of eels.'''
30+
31+
32+ try :
33+ raise MyBaseException ()
34+ except BaseException , base_exception :
35+ assert base_exception .message == '''My hovercraft is full of eels.'''
36+ else :
37+ raise cute_testing .Failure
38+
39+ try :
40+ raise MyBaseException
41+ except BaseException , base_exception :
42+ assert base_exception .message == '''My hovercraft is full of eels.'''
43+ else :
44+ raise cute_testing .Failure
Original file line number Diff line number Diff line change 1+ # Copyright 2009-2011 Ram Rachum.
2+ # This program is distributed under the LGPL2.1 license.
3+
4+ '''Testing package for `exceptions.CuteException`.'''
5+
6+ from garlicsim .general_misc import cute_testing
7+
8+ from garlicsim .general_misc .exceptions import CuteBaseException , CuteException
9+
10+
11+ def test ():
12+
13+ try :
14+ raise CuteException
15+ except Exception , exception :
16+ assert exception .message == ''
17+ else :
18+ raise cute_testing .Failure
19+
20+ try :
21+ raise CuteException ()
22+ except Exception , exception :
23+ assert exception .message == ''
24+ else :
25+ raise cute_testing .Failure
26+
27+
28+ class MyException (CuteException ):
29+ '''My hovercraft is full of eels.'''
30+
31+
32+ try :
33+ raise MyException ()
34+ except Exception , exception :
35+ assert exception .message == '''My hovercraft is full of eels.'''
36+ else :
37+ raise cute_testing .Failure
38+
39+ try :
40+ raise MyException
41+ except Exception , exception :
42+ assert exception .message == '''My hovercraft is full of eels.'''
43+ else :
44+ raise cute_testing .Failure
You can’t perform that action at this time.
0 commit comments