Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
C
cpython
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Kirill Smelkov
cpython
Commits
e08940ef
Commit
e08940ef
authored
Jun 01, 2006
by
Georg Brandl
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Some code style tweaks, and remove apply.
parent
b9120e77
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
67 additions
and
63 deletions
+67
-63
Lib/test/test_exceptions.py
Lib/test/test_exceptions.py
+67
-63
No files found.
Lib/test/test_exceptions.py
View file @
e08940ef
...
...
@@ -189,69 +189,68 @@ class ExceptionTests(unittest.TestCase):
except
Exception
,
e
:
sampleUnicodeDecodeError
=
e
exceptionList
=
[
(
BaseException
,
(),
{
'message'
:
''
,
'args'
:
()
}),
(
BaseException
,
(
1
,
),
{
'message'
:
1
,
'args'
:
(
1
,
)
}),
(
BaseException
,
(
'foo'
,
),
{
'message'
:
'foo'
,
'args'
:
(
'foo'
,
)
}),
(
BaseException
,
(
'foo'
,
1
),
{
'message'
:
''
,
'args'
:
(
'foo'
,
1
)
}),
(
SystemExit
,
(
'foo'
,),
{
'message'
:
'foo'
,
'args'
:
(
'foo'
,
),
'code'
:
'foo'
}),
(
IOError
,
(
'foo'
,),
{
'message'
:
'foo'
,
'args'
:
(
'foo'
,
),
}),
(
IOError
,
(
'foo'
,
'bar'
),
{
'message'
:
''
,
'args'
:
(
'foo'
,
'bar'
),
}),
(
IOError
,
(
'foo'
,
'bar'
,
'baz'
),
{
'message'
:
''
,
'args'
:
(
'foo'
,
'bar'
),
}),
(
EnvironmentError
,
(
'errnoStr'
,
'strErrorStr'
,
'filenameStr'
),
{
'message'
:
''
,
'args'
:
(
'errnoStr'
,
'strErrorStr'
),
'strerror'
:
'strErrorStr'
,
'errno'
:
'errnoStr'
,
'filename'
:
'filenameStr'
}),
(
EnvironmentError
,
(
1
,
'strErrorStr'
,
'filenameStr'
),
{
'message'
:
''
,
'args'
:
(
1
,
'strErrorStr'
),
'strerror'
:
'strErrorStr'
,
'errno'
:
1
,
'filename'
:
'filenameStr'
}),
(
SyntaxError
,
(
'msgStr'
,),
{
'message'
:
'msgStr'
,
'args'
:
(
'msgStr'
,
),
'print_file_and_line'
:
None
,
'msg'
:
'msgStr'
,
'filename'
:
None
,
'lineno'
:
None
,
'offset'
:
None
,
'text'
:
None
}),
(
SyntaxError
,
(
'msgStr'
,
(
'filenameStr'
,
'linenoStr'
,
'offsetStr'
,
'textStr'
)),
{
'message'
:
''
,
'args'
:
(
'msgStr'
,
(
'filenameStr'
,
'linenoStr'
,
'offsetStr'
,
'textStr'
)),
'print_file_and_line'
:
None
,
'msg'
:
'msgStr'
,
'filename'
:
'filenameStr'
,
'lineno'
:
'linenoStr'
,
'offset'
:
'offsetStr'
,
'text'
:
'textStr'
}),
(
SyntaxError
,
(
'msgStr'
,
'filenameStr'
,
'linenoStr'
,
'offsetStr'
,
'textStr'
,
'print_file_and_lineStr'
),
{
'message'
:
''
,
'args'
:
(
'msgStr'
,
'filenameStr'
,
'linenoStr'
,
'offsetStr'
,
'textStr'
,
'print_file_and_lineStr'
),
'print_file_and_line'
:
None
,
'msg'
:
'msgStr'
,
'filename'
:
None
,
'lineno'
:
None
,
'offset'
:
None
,
'text'
:
None
}),
(
UnicodeError
,
(),
{
'message'
:
''
,
'args'
:
(),
}),
(
sampleUnicodeEncodeError
,
{
'message'
:
''
,
'args'
:
(
'ascii'
,
u'Hello
\
xe1
'
,
6
,
7
,
'ordinal not in range(128)'
),
'encoding'
:
'ascii'
,
'object'
:
u'Hello
\
xe1
'
,
'start'
:
6
,
'reason'
:
'ordinal not in range(128)'
}),
(
sampleUnicodeDecodeError
,
{
'message'
:
''
,
'args'
:
(
'ascii'
,
'
\
xff
'
,
0
,
1
,
'ordinal not in range(128)'
),
'encoding'
:
'ascii'
,
'object'
:
'
\
xff
'
,
'start'
:
0
,
'reason'
:
'ordinal not in range(128)'
}),
(
UnicodeTranslateError
,
(
u"
\
u3042
"
,
0
,
1
,
"ouch"
),
{
'message'
:
''
,
'args'
:
(
u'
\
u3042
'
,
0
,
1
,
'ouch'
),
'object'
:
u'
\
u3042
'
,
'reason'
:
'ouch'
,
'start'
:
0
,
'end'
:
1
}),
]
(
BaseException
,
(),
{
'message'
:
''
,
'args'
:
()}),
(
BaseException
,
(
1
,
),
{
'message'
:
1
,
'args'
:
(
1
,)}),
(
BaseException
,
(
'foo'
,),
{
'message'
:
'foo'
,
'args'
:
(
'foo'
,)}),
(
BaseException
,
(
'foo'
,
1
),
{
'message'
:
''
,
'args'
:
(
'foo'
,
1
)}),
(
SystemExit
,
(
'foo'
,),
{
'message'
:
'foo'
,
'args'
:
(
'foo'
,),
'code'
:
'foo'
}),
(
IOError
,
(
'foo'
,),
{
'message'
:
'foo'
,
'args'
:
(
'foo'
,)}),
(
IOError
,
(
'foo'
,
'bar'
),
{
'message'
:
''
,
'args'
:
(
'foo'
,
'bar'
)}),
(
IOError
,
(
'foo'
,
'bar'
,
'baz'
),
{
'message'
:
''
,
'args'
:
(
'foo'
,
'bar'
)}),
(
EnvironmentError
,
(
'errnoStr'
,
'strErrorStr'
,
'filenameStr'
),
{
'message'
:
''
,
'args'
:
(
'errnoStr'
,
'strErrorStr'
),
'strerror'
:
'strErrorStr'
,
'errno'
:
'errnoStr'
,
'filename'
:
'filenameStr'
}),
(
EnvironmentError
,
(
1
,
'strErrorStr'
,
'filenameStr'
),
{
'message'
:
''
,
'args'
:
(
1
,
'strErrorStr'
),
'errno'
:
1
,
'strerror'
:
'strErrorStr'
,
'filename'
:
'filenameStr'
}),
(
SyntaxError
,
(
'msgStr'
,),
{
'message'
:
'msgStr'
,
'args'
:
(
'msgStr'
,),
'text'
:
None
,
'print_file_and_line'
:
None
,
'msg'
:
'msgStr'
,
'filename'
:
None
,
'lineno'
:
None
,
'offset'
:
None
}),
(
SyntaxError
,
(
'msgStr'
,
(
'filenameStr'
,
'linenoStr'
,
'offsetStr'
,
'textStr'
)),
{
'message'
:
''
,
'offset'
:
'offsetStr'
,
'text'
:
'textStr'
,
'args'
:
(
'msgStr'
,
(
'filenameStr'
,
'linenoStr'
,
'offsetStr'
,
'textStr'
)),
'print_file_and_line'
:
None
,
'msg'
:
'msgStr'
,
'filename'
:
'filenameStr'
,
'lineno'
:
'linenoStr'
}),
(
SyntaxError
,
(
'msgStr'
,
'filenameStr'
,
'linenoStr'
,
'offsetStr'
,
'textStr'
,
'print_file_and_lineStr'
),
{
'message'
:
''
,
'text'
:
None
,
'args'
:
(
'msgStr'
,
'filenameStr'
,
'linenoStr'
,
'offsetStr'
,
'textStr'
,
'print_file_and_lineStr'
),
'print_file_and_line'
:
None
,
'msg'
:
'msgStr'
,
'filename'
:
None
,
'lineno'
:
None
,
'offset'
:
None
}),
(
UnicodeError
,
(),
{
'message'
:
''
,
'args'
:
(),}),
(
sampleUnicodeEncodeError
,
{
'message'
:
''
,
'args'
:
(
'ascii'
,
u'Hello
\
xe1
'
,
6
,
7
,
'ordinal not in range(128)'
),
'encoding'
:
'ascii'
,
'object'
:
u'Hello
\
xe1
'
,
'start'
:
6
,
'reason'
:
'ordinal not in range(128)'
}),
(
sampleUnicodeDecodeError
,
{
'message'
:
''
,
'args'
:
(
'ascii'
,
'
\
xff
'
,
0
,
1
,
'ordinal not in range(128)'
),
'encoding'
:
'ascii'
,
'object'
:
'
\
xff
'
,
'start'
:
0
,
'reason'
:
'ordinal not in range(128)'
}),
(
UnicodeTranslateError
,
(
u"
\
u3042
"
,
0
,
1
,
"ouch"
),
{
'message'
:
''
,
'args'
:
(
u'
\
u3042
'
,
0
,
1
,
'ouch'
),
'object'
:
u'
\
u3042
'
,
'reason'
:
'ouch'
,
'start'
:
0
,
'end'
:
1
}),
]
try
:
exceptionList
.
append
(
(
WindowsError
,
(
1
,
'strErrorStr'
,
'filenameStr'
),
{
'message'
:
''
,
'args'
:
(
1
,
'strErrorStr'
),
'strerror'
:
'strErrorStr'
,
'errno'
:
22
,
'filename'
:
'filenameStr'
,
'winerror'
:
1
})
)
(
WindowsError
,
(
1
,
'strErrorStr'
,
'filenameStr'
),
{
'message'
:
''
,
'args'
:
(
1
,
'strErrorStr'
),
'strerror'
:
'strErrorStr'
,
'winerror'
:
1
,
'errno'
:
22
,
'filename'
:
'filenameStr'
})
)
except
NameError
:
pass
import
pickle
,
random
...
...
@@ -259,9 +258,13 @@ class ExceptionTests(unittest.TestCase):
for
args
in
exceptionList
:
expected
=
args
[
-
1
]
try
:
if
len
(
args
)
==
2
:
raise
args
[
0
]
else
:
raise
apply
(
args
[
0
],
args
[
1
])
exc
=
args
[
0
]
if
len
(
args
)
==
2
:
raise
exc
else
:
raise
exc
(
*
args
[
1
])
except
BaseException
,
e
:
if
(
e
is
not
exc
and
# needed for sampleUnicode errors
type
(
e
)
is
not
exc
):
raise
for
checkArgName
in
expected
.
keys
():
self
.
assertEquals
(
repr
(
getattr
(
e
,
checkArgName
)),
repr
(
expected
[
checkArgName
]),
...
...
@@ -280,6 +283,7 @@ class ExceptionTests(unittest.TestCase):
"""test that builtin exception don't take keyword args,
but user-defined subclasses can if they want"""
self
.
assertRaises
(
TypeError
,
BaseException
,
a
=
1
)
class
DerivedException
(
BaseException
):
def
__init__
(
self
,
fancy_arg
):
BaseException
.
__init__
(
self
)
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment