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
3add4d78
Commit
3add4d78
authored
Aug 29, 2007
by
Collin Winter
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Raise statement normalization in Lib/test/.
parent
e0281cab
Changes
47
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
47 changed files
with
218 additions
and
218 deletions
+218
-218
Lib/test/leakers/test_gestalt.py
Lib/test/leakers/test_gestalt.py
+1
-1
Lib/test/pickletester.py
Lib/test/pickletester.py
+1
-1
Lib/test/test_binop.py
Lib/test/test_binop.py
+6
-6
Lib/test/test_capi.py
Lib/test/test_capi.py
+3
-6
Lib/test/test_cgi.py
Lib/test/test_cgi.py
+1
-1
Lib/test/test_contains.py
Lib/test/test_contains.py
+2
-2
Lib/test/test_copy.py
Lib/test/test_copy.py
+5
-5
Lib/test/test_curses.py
Lib/test/test_curses.py
+4
-4
Lib/test/test_dbm.py
Lib/test/test_dbm.py
+1
-1
Lib/test/test_descr.py
Lib/test/test_descr.py
+70
-70
Lib/test/test_descrtut.py
Lib/test/test_descrtut.py
+1
-1
Lib/test/test_dl.py
Lib/test/test_dl.py
+1
-1
Lib/test/test_doctest.py
Lib/test/test_doctest.py
+6
-6
Lib/test/test_exception_variations.py
Lib/test/test_exception_variations.py
+6
-6
Lib/test/test_extcall.py
Lib/test/test_extcall.py
+2
-2
Lib/test/test_fork1.py
Lib/test/test_fork1.py
+1
-1
Lib/test/test_format.py
Lib/test/test_format.py
+2
-2
Lib/test/test_funcattrs.py
Lib/test/test_funcattrs.py
+24
-24
Lib/test/test_gdbm.py
Lib/test/test_gdbm.py
+2
-2
Lib/test/test_importhooks.py
Lib/test/test_importhooks.py
+1
-1
Lib/test/test_iter.py
Lib/test/test_iter.py
+1
-1
Lib/test/test_largefile.py
Lib/test/test_largefile.py
+4
-4
Lib/test/test_locale.py
Lib/test/test_locale.py
+9
-6
Lib/test/test_logging.py
Lib/test/test_logging.py
+1
-1
Lib/test/test_openpty.py
Lib/test/test_openpty.py
+1
-1
Lib/test/test_pep277.py
Lib/test/test_pep277.py
+1
-1
Lib/test/test_pkgimport.py
Lib/test/test_pkgimport.py
+2
-2
Lib/test/test_poll.py
Lib/test/test_poll.py
+3
-3
Lib/test/test_posix.py
Lib/test/test_posix.py
+1
-1
Lib/test/test_pty.py
Lib/test/test_pty.py
+1
-1
Lib/test/test_queue.py
Lib/test/test_queue.py
+4
-4
Lib/test/test_re.py
Lib/test/test_re.py
+1
-1
Lib/test/test_richcmp.py
Lib/test/test_richcmp.py
+9
-9
Lib/test/test_scope.py
Lib/test/test_scope.py
+1
-1
Lib/test/test_socket.py
Lib/test/test_socket.py
+2
-2
Lib/test/test_socketserver.py
Lib/test/test_socketserver.py
+1
-1
Lib/test/test_struct.py
Lib/test/test_struct.py
+19
-19
Lib/test/test_thread.py
Lib/test/test_thread.py
+4
-4
Lib/test/test_threadsignals.py
Lib/test/test_threadsignals.py
+1
-1
Lib/test/test_trace.py
Lib/test/test_trace.py
+2
-2
Lib/test/test_traceback.py
Lib/test/test_traceback.py
+1
-1
Lib/test/test_unicode_file.py
Lib/test/test_unicode_file.py
+1
-1
Lib/test/test_univnewlines.py
Lib/test/test_univnewlines.py
+2
-2
Lib/test/test_wait3.py
Lib/test/test_wait3.py
+2
-2
Lib/test/test_wait4.py
Lib/test/test_wait4.py
+2
-2
Lib/test/test_wave.py
Lib/test/test_wave.py
+1
-1
Lib/test/time_hashlib.py
Lib/test/time_hashlib.py
+1
-1
No files found.
Lib/test/leakers/test_gestalt.py
View file @
3add4d78
import
sys
if
sys
.
platform
!=
'darwin'
:
raise
ValueError
,
"This test only leaks on Mac OS X"
raise
ValueError
(
"This test only leaks on Mac OS X"
)
def
leak
():
# taken from platform._mac_ver_lookup()
...
...
Lib/test/pickletester.py
View file @
3add4d78
...
...
@@ -868,7 +868,7 @@ class REX_three(object):
self
.
_proto
=
proto
return
REX_two
,
()
def
__reduce__
(
self
):
raise
TestFailed
,
"This __reduce__ shouldn't be called"
raise
TestFailed
(
"This __reduce__ shouldn't be called"
)
class
REX_four
(
object
):
_proto
=
None
...
...
Lib/test/test_binop.py
View file @
3add4d78
...
...
@@ -35,12 +35,12 @@ class Rat(object):
The arguments must be ints or longs, and default to (0, 1)."""
if
not
isint
(
num
):
raise
TypeError
,
"Rat numerator must be int or long (%r)"
%
num
raise
TypeError
(
"Rat numerator must be int or long (%r)"
%
num
)
if
not
isint
(
den
):
raise
TypeError
,
"Rat denominator must be int or long (%r)"
%
den
raise
TypeError
(
"Rat denominator must be int or long (%r)"
%
den
)
# But the zero is always on
if
den
==
0
:
raise
ZeroDivisionError
,
"zero denominator"
raise
ZeroDivisionError
(
"zero denominator"
)
g
=
gcd
(
den
,
num
)
self
.
__num
=
int
(
num
//
g
)
self
.
__den
=
int
(
den
//
g
)
...
...
@@ -73,15 +73,15 @@ class Rat(object):
try
:
return
int
(
self
.
__num
)
except
OverflowError
:
raise
OverflowError
,
(
"%s too large to convert to int"
%
raise
OverflowError
(
"%s too large to convert to int"
%
repr
(
self
))
raise
ValueError
,
"can't convert %s to int"
%
repr
(
self
)
raise
ValueError
(
"can't convert %s to int"
%
repr
(
self
)
)
def
__long__
(
self
):
"""Convert a Rat to an long; self.den must be 1."""
if
self
.
__den
==
1
:
return
int
(
self
.
__num
)
raise
ValueError
,
"can't convert %s to long"
%
repr
(
self
)
raise
ValueError
(
"can't convert %s to long"
%
repr
(
self
)
)
def
__add__
(
self
,
other
):
"""Add two Rats, or a Rat and a number."""
...
...
Lib/test/test_capi.py
View file @
3add4d78
...
...
@@ -12,10 +12,7 @@ def test_main():
test
=
getattr
(
_testcapi
,
name
)
if
test_support
.
verbose
:
print
(
"internal"
,
name
)
try
:
test
()
except
_testcapi
.
error
:
raise
test_support
.
TestFailed
,
sys
.
exc_info
()[
1
]
test
()
# some extra thread-state tests driven via _testcapi
def
TestThreadState
():
...
...
@@ -35,8 +32,8 @@ def test_main():
time
.
sleep
(
1
)
# Check our main thread is in the list exactly 3 times.
if
idents
.
count
(
thread
.
get_ident
())
!=
3
:
raise
test_support
.
TestFailed
,
\
"Couldn't find main thread correctly in the list"
raise
test_support
.
TestFailed
(
"Couldn't find main thread correctly in the list"
)
try
:
_testcapi
.
_test_thread_state
...
...
Lib/test/test_cgi.py
View file @
3add4d78
...
...
@@ -47,7 +47,7 @@ def do_test(buf, method):
env
[
'CONTENT_TYPE'
]
=
'application/x-www-form-urlencoded'
env
[
'CONTENT_LENGTH'
]
=
str
(
len
(
buf
))
else
:
raise
ValueError
,
"unknown method: %s"
%
method
raise
ValueError
(
"unknown method: %s"
%
method
)
try
:
return
cgi
.
parse
(
fp
,
env
,
strict_parsing
=
1
)
except
Exception
as
err
:
...
...
Lib/test/test_contains.py
View file @
3add4d78
...
...
@@ -17,7 +17,7 @@ class seq(base_set):
def
check
(
ok
,
*
args
):
if
not
ok
:
raise
TestFailed
,
" "
.
join
(
map
(
str
,
args
))
raise
TestFailed
(
" "
.
join
(
map
(
str
,
args
)
))
a
=
base_set
(
1
)
b
=
set
(
1
)
...
...
@@ -95,7 +95,7 @@ class Deviant2:
def
__cmp__
(
self
,
other
):
if
other
==
4
:
raise
RuntimeError
,
"gotcha"
raise
RuntimeError
(
"gotcha"
)
try
:
check
(
Deviant2
()
not
in
a
,
"oops"
)
...
...
Lib/test/test_copy.py
View file @
3add4d78
...
...
@@ -51,7 +51,7 @@ class TestCopy(unittest.TestCase):
def
__reduce_ex__
(
self
,
proto
):
return
""
def
__reduce__
(
self
):
raise
test_support
.
TestFailed
,
"shouldn't call this"
raise
test_support
.
TestFailed
(
"shouldn't call this"
)
x
=
C
()
y
=
copy
.
copy
(
x
)
self
.
assert_
(
y
is
x
)
...
...
@@ -68,7 +68,7 @@ class TestCopy(unittest.TestCase):
class
C
(
object
):
def
__getattribute__
(
self
,
name
):
if
name
.
startswith
(
"__reduce"
):
raise
AttributeError
,
name
raise
AttributeError
(
name
)
return
object
.
__getattribute__
(
self
,
name
)
x
=
C
()
self
.
assertRaises
(
copy
.
Error
,
copy
.
copy
,
x
)
...
...
@@ -224,7 +224,7 @@ class TestCopy(unittest.TestCase):
def
__reduce_ex__
(
self
,
proto
):
return
""
def
__reduce__
(
self
):
raise
test_support
.
TestFailed
,
"shouldn't call this"
raise
test_support
.
TestFailed
(
"shouldn't call this"
)
x
=
C
()
y
=
copy
.
deepcopy
(
x
)
self
.
assert_
(
y
is
x
)
...
...
@@ -241,7 +241,7 @@ class TestCopy(unittest.TestCase):
class
C
(
object
):
def
__getattribute__
(
self
,
name
):
if
name
.
startswith
(
"__reduce"
):
raise
AttributeError
,
name
raise
AttributeError
(
name
)
return
object
.
__getattribute__
(
self
,
name
)
x
=
C
()
self
.
assertRaises
(
copy
.
Error
,
copy
.
deepcopy
,
x
)
...
...
@@ -565,7 +565,7 @@ class TestCopy(unittest.TestCase):
def
test_getstate_exc
(
self
):
class
EvilState
(
object
):
def
__getstate__
(
self
):
raise
ValueError
,
"ain't got no stickin' state"
raise
ValueError
(
"ain't got no stickin' state"
)
self
.
assertRaises
(
ValueError
,
copy
.
copy
,
EvilState
())
def
test_copy_function
(
self
):
...
...
Lib/test/test_curses.py
View file @
3add4d78
...
...
@@ -22,7 +22,7 @@ requires('curses')
# XXX: if newterm was supported we could use it instead of initscr and not exit
term
=
os
.
environ
.
get
(
'TERM'
)
if
not
term
or
term
==
'unknown'
:
raise
TestSkipped
,
"$TERM=%r, calling initscr() may cause exit"
%
term
raise
TestSkipped
(
"$TERM=%r, calling initscr() may cause exit"
%
term
)
if
sys
.
platform
==
"cygwin"
:
raise
TestSkipped
(
"cygwin's curses mostly just hangs"
)
...
...
@@ -72,7 +72,7 @@ def window_funcs(stdscr):
except
TypeError
:
pass
else
:
raise
RuntimeError
,
"Expected win.border() to raise TypeError"
raise
RuntimeError
(
"Expected win.border() to raise TypeError"
)
stdscr
.
clearok
(
1
)
...
...
@@ -243,7 +243,7 @@ def test_userptr_without_set(stdscr):
# try to access userptr() before calling set_userptr() -- segfaults
try
:
p
.
userptr
()
raise
RuntimeError
,
'userptr should fail since not set'
raise
RuntimeError
(
'userptr should fail since not set'
)
except
curses
.
panel
.
error
:
pass
...
...
@@ -253,7 +253,7 @@ def test_resize_term(stdscr):
curses
.
resizeterm
(
lines
-
1
,
cols
+
1
)
if
curses
.
LINES
!=
lines
-
1
or
curses
.
COLS
!=
cols
+
1
:
raise
RuntimeError
,
"Expected resizeterm to update LINES and COLS"
raise
RuntimeError
(
"Expected resizeterm to update LINES and COLS"
)
def
main
(
stdscr
):
curses
.
savetty
()
...
...
Lib/test/test_dbm.py
View file @
3add4d78
...
...
@@ -21,7 +21,7 @@ def cleanup():
# if we can't delete the file because of permissions,
# nothing will work, so skip the test
if
errno
==
1
:
raise
TestSkipped
,
'unable to remove: '
+
filename
+
suffix
raise
TestSkipped
(
'unable to remove: '
+
filename
+
suffix
)
def
test_keys
():
d
=
dbm
.
open
(
filename
,
'c'
)
...
...
Lib/test/test_descr.py
View file @
3add4d78
This diff is collapsed.
Click to expand it.
Lib/test/test_descrtut.py
View file @
3add4d78
...
...
@@ -313,7 +313,7 @@ Attributes defined by get/set methods
...
... def __set__(self, inst, value):
... if self.__set is None:
... raise AttributeError
, "this attribute is read-only"
... raise AttributeError
("this attribute is read-only")
... return self.__set(inst, value)
Now let's define a class with an attribute x defined by a pair of methods,
...
...
Lib/test/test_dl.py
View file @
3add4d78
...
...
@@ -31,4 +31,4 @@ for s, func in sharedlibs:
print
(
'worked!'
)
break
else
:
raise
TestSkipped
,
'Could not open any shared libraries'
raise
TestSkipped
(
'Could not open any shared libraries'
)
Lib/test/test_doctest.py
View file @
3add4d78
...
...
@@ -811,7 +811,7 @@ Exception messages may contain newlines:
>>> def f(x):
... r'''
... >>> raise ValueError
, 'multi\nline\nmessage'
... >>> raise ValueError
('multi\nline\nmessage')
... Traceback (most recent call last):
... ValueError: multi
... line
...
...
@@ -826,7 +826,7 @@ message is raised, then it is reported as a failure:
>>> def f(x):
... r'''
... >>> raise ValueError
, 'message'
... >>> raise ValueError
('message')
... Traceback (most recent call last):
... ValueError: wrong message
... '''
...
...
@@ -836,7 +836,7 @@ message is raised, then it is reported as a failure:
**********************************************************************
File ..., line 3, in f
Failed example:
raise ValueError
, 'message'
raise ValueError
('message')
Expected:
Traceback (most recent call last):
ValueError: wrong message
...
...
@@ -851,7 +851,7 @@ detail:
>>> def f(x):
... r'''
... >>> raise ValueError
, 'message'
#doctest: +IGNORE_EXCEPTION_DETAIL
... >>> raise ValueError
('message')
#doctest: +IGNORE_EXCEPTION_DETAIL
... Traceback (most recent call last):
... ValueError: wrong message
... '''
...
...
@@ -863,7 +863,7 @@ But IGNORE_EXCEPTION_DETAIL does not allow a mismatch in the exception type:
>>> def f(x):
... r'''
... >>> raise ValueError
, 'message'
#doctest: +IGNORE_EXCEPTION_DETAIL
... >>> raise ValueError
('message')
#doctest: +IGNORE_EXCEPTION_DETAIL
... Traceback (most recent call last):
... TypeError: wrong type
... '''
...
...
@@ -873,7 +873,7 @@ But IGNORE_EXCEPTION_DETAIL does not allow a mismatch in the exception type:
**********************************************************************
File ..., line 3, in f
Failed example:
raise ValueError
, 'message'
#doctest: +IGNORE_EXCEPTION_DETAIL
raise ValueError
('message')
#doctest: +IGNORE_EXCEPTION_DETAIL
Expected:
Traceback (most recent call last):
TypeError: wrong type
...
...
Lib/test/test_exception_variations.py
View file @
3add4d78
...
...
@@ -9,7 +9,7 @@ class ExceptionTestCase(unittest.TestCase):
hit_finally
=
False
try
:
raise
Exception
,
'nyaa!'
raise
Exception
(
'nyaa!'
)
except
:
hit_except
=
True
else
:
...
...
@@ -44,7 +44,7 @@ class ExceptionTestCase(unittest.TestCase):
hit_finally
=
False
try
:
raise
Exception
,
'yarr!'
raise
Exception
(
'yarr!'
)
except
:
hit_except
=
True
finally
:
...
...
@@ -71,7 +71,7 @@ class ExceptionTestCase(unittest.TestCase):
hit_except
=
False
try
:
raise
Exception
,
'ahoy!'
raise
Exception
(
'ahoy!'
)
except
:
hit_except
=
True
...
...
@@ -92,7 +92,7 @@ class ExceptionTestCase(unittest.TestCase):
hit_else
=
False
try
:
raise
Exception
,
'foo!'
raise
Exception
(
'foo!'
)
except
:
hit_except
=
True
else
:
...
...
@@ -132,7 +132,7 @@ class ExceptionTestCase(unittest.TestCase):
try
:
try
:
raise
Exception
,
'inner exception'
raise
Exception
(
'inner exception'
)
except
:
hit_inner_except
=
True
finally
:
...
...
@@ -159,7 +159,7 @@ class ExceptionTestCase(unittest.TestCase):
else
:
hit_inner_else
=
True
raise
Exception
,
'outer exception'
raise
Exception
(
'outer exception'
)
except
:
hit_except
=
True
else
:
...
...
Lib/test/test_extcall.py
View file @
3add4d78
...
...
@@ -90,7 +90,7 @@ class Nothing:
if
i
<
3
:
return
i
else
:
raise
IndexError
,
i
raise
IndexError
(
i
)
g
(
*
Nothing
())
class
Nothing
:
...
...
@@ -253,7 +253,7 @@ try:
except
TypeError
:
pass
else
:
raise
TestFailed
,
'expected TypeError; no exception raised'
raise
TestFailed
(
'expected TypeError; no exception raised'
)
a
,
b
,
d
,
e
,
v
,
k
=
'A'
,
'B'
,
'D'
,
'E'
,
'V'
,
'K'
funcs
=
[]
...
...
Lib/test/test_fork1.py
View file @
3add4d78
...
...
@@ -9,7 +9,7 @@ from test.test_support import TestSkipped, run_unittest, reap_children
try
:
os
.
fork
except
AttributeError
:
raise
TestSkipped
,
"os.fork not defined -- skipping test_fork1"
raise
TestSkipped
(
"os.fork not defined -- skipping test_fork1"
)
class
ForkTest
(
ForkWait
):
def
wait_impl
(
self
,
cpid
):
...
...
Lib/test/test_format.py
View file @
3add4d78
...
...
@@ -216,7 +216,7 @@ def test_exc(formatstr, args, exception, excmsg):
print
(
'Unexpected exception'
)
raise
else
:
raise
TestFailed
,
'did not get expected exception: %s'
%
excmsg
raise
TestFailed
(
'did not get expected exception: %s'
%
excmsg
)
test_exc
(
'abc %a'
,
1
,
ValueError
,
"unsupported format character 'a' (0x61) at index 5"
)
...
...
@@ -241,4 +241,4 @@ if maxsize == 2**31-1:
except
MemoryError
:
pass
else
:
raise
TestFailed
,
'"%*d"%(maxsize, -127) should fail'
raise
TestFailed
(
'"%*d"%(maxsize, -127) should fail'
)
Lib/test/test_funcattrs.py
View file @
3add4d78
...
...
@@ -17,40 +17,40 @@ verify(verify.__module__ == "test.test_support")
try
:
b
.
publish
except
AttributeError
:
pass
else
:
raise
TestFailed
,
'expected AttributeError'
else
:
raise
TestFailed
(
'expected AttributeError'
)
if
b
.
__dict__
!=
{}:
raise
TestFailed
,
'expected unassigned func.__dict__ to be {}'
raise
TestFailed
(
'expected unassigned func.__dict__ to be {}'
)
b
.
publish
=
1
if
b
.
publish
!=
1
:
raise
TestFailed
,
'function attribute not set to expected value'
raise
TestFailed
(
'function attribute not set to expected value'
)
docstring
=
'its docstring'
b
.
__doc__
=
docstring
if
b
.
__doc__
!=
docstring
:
raise
TestFailed
,
'problem with setting __doc__ attribute'
raise
TestFailed
(
'problem with setting __doc__ attribute'
)
if
'publish'
not
in
dir
(
b
):
raise
TestFailed
,
'attribute not in dir()'
raise
TestFailed
(
'attribute not in dir()'
)
try
:
del
b
.
__dict__
except
TypeError
:
pass
else
:
raise
TestFailed
,
'del func.__dict__ expected TypeError'
else
:
raise
TestFailed
(
'del func.__dict__ expected TypeError'
)
b
.
publish
=
1
try
:
b
.
__dict__
=
None
except
TypeError
:
pass
else
:
raise
TestFailed
,
'func.__dict__ = None expected TypeError'
else
:
raise
TestFailed
(
'func.__dict__ = None expected TypeError'
)
d
=
{
'hello'
:
'world'
}
b
.
__dict__
=
d
if
b
.
__dict__
is
not
d
:
raise
TestFailed
,
'func.__dict__ assignment to dictionary failed'
raise
TestFailed
(
'func.__dict__ assignment to dictionary failed'
)
if
b
.
hello
!=
'world'
:
raise
TestFailed
,
'attribute after func.__dict__ assignment failed'
raise
TestFailed
(
'attribute after func.__dict__ assignment failed'
)
f1
=
F
()
f2
=
F
()
...
...
@@ -58,45 +58,45 @@ f2 = F()
try
:
F
.
a
.
publish
except
AttributeError
:
pass
else
:
raise
TestFailed
,
'expected AttributeError'
else
:
raise
TestFailed
(
'expected AttributeError'
)
try
:
f1
.
a
.
publish
except
AttributeError
:
pass
else
:
raise
TestFailed
,
'expected AttributeError'
else
:
raise
TestFailed
(
'expected AttributeError'
)
# In Python 2.1 beta 1, we disallowed setting attributes on unbound methods
# (it was already disallowed on bound methods). See the PEP for details.
try
:
F
.
a
.
publish
=
1
except
(
AttributeError
,
TypeError
):
pass
else
:
raise
TestFailed
,
'expected AttributeError or TypeError'
else
:
raise
TestFailed
(
'expected AttributeError or TypeError'
)
# But setting it explicitly on the underlying function object is okay.
F
.
a
.
im_func
.
publish
=
1
if
F
.
a
.
publish
!=
1
:
raise
TestFailed
,
'unbound method attribute not set to expected value'
raise
TestFailed
(
'unbound method attribute not set to expected value'
)
if
f1
.
a
.
publish
!=
1
:
raise
TestFailed
,
'bound method attribute access did not work'
raise
TestFailed
(
'bound method attribute access did not work'
)
if
f2
.
a
.
publish
!=
1
:
raise
TestFailed
,
'bound method attribute access did not work'
raise
TestFailed
(
'bound method attribute access did not work'
)
if
'publish'
not
in
dir
(
F
.
a
):
raise
TestFailed
,
'attribute not in dir()'
raise
TestFailed
(
'attribute not in dir()'
)
try
:
f1
.
a
.
publish
=
0
except
(
AttributeError
,
TypeError
):
pass
else
:
raise
TestFailed
,
'expected AttributeError or TypeError'
else
:
raise
TestFailed
(
'expected AttributeError or TypeError'
)
# See the comment above about the change in semantics for Python 2.1b1
try
:
F
.
a
.
myclass
=
F
except
(
AttributeError
,
TypeError
):
pass
else
:
raise
TestFailed
,
'expected AttributeError or TypeError'
else
:
raise
TestFailed
(
'expected AttributeError or TypeError'
)
F
.
a
.
im_func
.
myclass
=
F
...
...
@@ -107,18 +107,18 @@ F.a.myclass
if
f1
.
a
.
myclass
is
not
f2
.
a
.
myclass
or
\
f1
.
a
.
myclass
is
not
F
.
a
.
myclass
:
raise
TestFailed
,
'attributes were not the same'
raise
TestFailed
(
'attributes were not the same'
)
# try setting __dict__
try
:
F
.
a
.
__dict__
=
(
1
,
2
,
3
)
except
(
AttributeError
,
TypeError
):
pass
else
:
raise
TestFailed
,
'expected TypeError or AttributeError'
else
:
raise
TestFailed
(
'expected TypeError or AttributeError'
)
F
.
a
.
im_func
.
__dict__
=
{
'one'
:
11
,
'two'
:
22
,
'three'
:
33
}
if
f1
.
a
.
two
!=
22
:
raise
TestFailed
,
'setting __dict__'
raise
TestFailed
(
'setting __dict__'
)
from
UserDict
import
UserDict
d
=
UserDict
({
'four'
:
44
,
'five'
:
55
})
...
...
@@ -225,13 +225,13 @@ def cantset(obj, name, value, exception=(AttributeError, TypeError)):
except
exception
:
pass
else
:
raise
TestFailed
,
"shouldn't be able to set %s to %r"
%
(
name
,
value
)
raise
TestFailed
(
"shouldn't be able to set %s to %r"
%
(
name
,
value
)
)
try
:
delattr
(
obj
,
name
)
except
(
AttributeError
,
TypeError
):
pass
else
:
raise
TestFailed
,
"shouldn't be able to del %s"
%
name
raise
TestFailed
(
"shouldn't be able to del %s"
%
name
)
def
test_func_closure
():
a
=
12
...
...
@@ -298,7 +298,7 @@ def test_func_defaults():
except
TypeError
:
pass
else
:
raise
TestFailed
,
"shouldn't be allowed to call g() w/o defaults"
raise
TestFailed
(
"shouldn't be allowed to call g() w/o defaults"
)
def
test_func_dict
():
def
f
():
pass
...
...
Lib/test/test_gdbm.py
View file @
3add4d78
...
...
@@ -24,7 +24,7 @@ try:
except
error
:
pass
else
:
raise
TestFailed
,
"expected gdbm.error accessing closed database"
raise
TestFailed
(
"expected gdbm.error accessing closed database"
)
g
=
gdbm
.
open
(
filename
,
'r'
)
g
.
close
()
g
=
gdbm
.
open
(
filename
,
'w'
)
...
...
@@ -37,7 +37,7 @@ try:
except
error
:
pass
else
:
raise
TestFailed
,
"expected gdbm.error when passing invalid open flags"
raise
TestFailed
(
"expected gdbm.error when passing invalid open flags"
)
try
:
import
os
...
...
Lib/test/test_importhooks.py
View file @
3add4d78
...
...
@@ -105,7 +105,7 @@ class ImportBlocker:
return
self
return
None
def
load_module
(
self
,
fullname
):
raise
ImportError
,
"I dare you"
raise
ImportError
(
"I dare you"
)
class
ImpWrapper
:
...
...
Lib/test/test_iter.py
View file @
3add4d78
...
...
@@ -825,7 +825,7 @@ class TestCase(unittest.TestCase):
i
=
state
[
0
]
state
[
0
]
=
i
+
1
if
i
==
10
:
raise
AssertionError
,
"shouldn't have gotten this far"
raise
AssertionError
(
"shouldn't have gotten this far"
)
return
i
b
=
iter
(
spam
,
5
)
self
.
assertEqual
(
list
(
b
),
list
(
range
(
5
)))
...
...
Lib/test/test_largefile.py
View file @
3add4d78
...
...
@@ -44,8 +44,8 @@ else:
except
(
IOError
,
OverflowError
):
f
.
close
()
os
.
unlink
(
test_support
.
TESTFN
)
raise
test_support
.
TestSkipped
,
\
"filesystem does not have largefile support"
raise
test_support
.
TestSkipped
(
"filesystem does not have largefile support"
)
else
:
f
.
close
()
...
...
@@ -56,8 +56,8 @@ def expect(got_this, expect_this):
if
got_this
!=
expect_this
:
if
test_support
.
verbose
:
print
(
'no'
)
raise
test_support
.
TestFailed
,
'got %r, but expected %r'
%
\
(
got_this
,
expect_this
)
raise
test_support
.
TestFailed
(
'got %r, but expected %r'
%
(
got_this
,
expect_this
)
)
else
:
if
test_support
.
verbose
:
print
(
'yes'
)
...
...
Lib/test/test_locale.py
View file @
3add4d78
...
...
@@ -3,7 +3,8 @@ import locale
import
sys
if
sys
.
platform
==
'darwin'
:
raise
TestSkipped
(
"Locale support on MacOSX is minimal and cannot be tested"
)
raise
TestSkipped
(
"Locale support on MacOSX is minimal and cannot be tested"
)
oldlocale
=
locale
.
setlocale
(
locale
.
LC_NUMERIC
)
if
sys
.
platform
.
startswith
(
"win"
):
...
...
@@ -18,20 +19,22 @@ for tloc in tlocs:
except
locale
.
Error
:
continue
else
:
raise
ImportError
,
"test locale not supported (tried %s)"
%
(
', '
.
join
(
tlocs
))
raise
ImportError
(
"test locale not supported (tried %s)"
%
(
', '
.
join
(
tlocs
)))
def
testformat
(
formatstr
,
value
,
grouping
=
0
,
output
=
None
,
func
=
locale
.
format
):
if
verbose
:
if
output
:
print
(
"%s %% %s =? %s ..."
%
\
(
repr
(
formatstr
),
repr
(
value
),
repr
(
output
)),
end
=
' '
)
print
(
"%s %% %s =? %s ..."
%
(
repr
(
formatstr
),
repr
(
value
),
repr
(
output
)),
end
=
' '
)
else
:
print
(
"%s %% %s works? ..."
%
(
repr
(
formatstr
),
repr
(
value
)),
end
=
' '
)
print
(
"%s %% %s works? ..."
%
(
repr
(
formatstr
),
repr
(
value
)),
end
=
' '
)
result
=
func
(
formatstr
,
value
,
grouping
=
grouping
)
if
output
and
result
!=
output
:
if
verbose
:
print
(
'no'
)
print
(
"%s %% %s == %s != %s"
%
\
print
(
"%s %% %s == %s != %s"
%
(
repr
(
formatstr
),
repr
(
value
),
repr
(
result
),
repr
(
output
)))
else
:
if
verbose
:
...
...
Lib/test/test_logging.py
View file @
3add4d78
...
...
@@ -595,7 +595,7 @@ def test_main_inner():
else
:
break
else
:
raise
ImportError
,
"Could not find unused port"
raise
ImportError
(
"Could not find unused port"
)
#Set up a handler such that all events are sent via a socket to the log
...
...
Lib/test/test_openpty.py
View file @
3add4d78
...
...
@@ -4,7 +4,7 @@ import os, unittest
from
test.test_support
import
run_unittest
,
TestSkipped
if
not
hasattr
(
os
,
"openpty"
):
raise
TestSkipped
,
"No openpty() available."
raise
TestSkipped
(
"No openpty() available."
)
class
OpenptyTest
(
unittest
.
TestCase
):
...
...
Lib/test/test_pep277.py
View file @
3add4d78
...
...
@@ -3,7 +3,7 @@
import
sys
,
os
,
unittest
from
test
import
test_support
if
not
os
.
path
.
supports_unicode_filenames
:
raise
test_support
.
TestSkipped
,
"test works only on NT+"
raise
test_support
.
TestSkipped
(
"test works only on NT+"
)
filenames
=
[
'abc'
,
...
...
Lib/test/test_pkgimport.py
View file @
3add4d78
...
...
@@ -51,7 +51,7 @@ class TestImport(unittest.TestCase):
self
.
rewrite_file
(
'for'
)
try
:
__import__
(
self
.
module_name
)
except
SyntaxError
:
pass
else
:
raise
RuntimeError
,
'Failed to induce SyntaxError'
else
:
raise
RuntimeError
(
'Failed to induce SyntaxError'
)
self
.
assert_
(
self
.
module_name
not
in
sys
.
modules
and
not
hasattr
(
sys
.
modules
[
self
.
package_name
],
'foo'
))
...
...
@@ -65,7 +65,7 @@ class TestImport(unittest.TestCase):
try
:
__import__
(
self
.
module_name
)
except
NameError
:
pass
else
:
raise
RuntimeError
,
'Failed to induce NameError.'
else
:
raise
RuntimeError
(
'Failed to induce NameError.'
)
# ...now change the module so that the NameError doesn't
# happen
...
...
Lib/test/test_poll.py
View file @
3add4d78
...
...
@@ -6,7 +6,7 @@ from test.test_support import TestSkipped, TESTFN, run_unittest
try
:
select
.
poll
except
AttributeError
:
raise
TestSkipped
,
"select.poll not defined -- skipping test_poll"
raise
TestSkipped
(
"select.poll not defined -- skipping test_poll"
)
def
find_ready_matching
(
ready
,
flag
):
...
...
@@ -47,14 +47,14 @@ class PollTests(unittest.TestCase):
ready
=
p
.
poll
()
ready_writers
=
find_ready_matching
(
ready
,
select
.
POLLOUT
)
if
not
ready_writers
:
raise
RuntimeError
,
"no pipes ready for writing"
raise
RuntimeError
(
"no pipes ready for writing"
)
wr
=
random
.
choice
(
ready_writers
)
os
.
write
(
wr
,
MSG
)
ready
=
p
.
poll
()
ready_readers
=
find_ready_matching
(
ready
,
select
.
POLLIN
)
if
not
ready_readers
:
raise
RuntimeError
,
"no pipes ready for reading"
raise
RuntimeError
(
"no pipes ready for reading"
)
rd
=
random
.
choice
(
ready_readers
)
buf
=
os
.
read
(
rd
,
MSG_LEN
)
self
.
assertEqual
(
len
(
buf
),
MSG_LEN
)
...
...
Lib/test/test_posix.py
View file @
3add4d78
...
...
@@ -5,7 +5,7 @@ from test import test_support
try
:
import
posix
except
ImportError
:
raise
test_support
.
TestSkipped
,
"posix is not available"
raise
test_support
.
TestSkipped
(
"posix is not available"
)
import
time
import
os
...
...
Lib/test/test_pty.py
View file @
3add4d78
...
...
@@ -69,7 +69,7 @@ class PtyTest(unittest.TestCase):
debug
(
"Got slave_fd '%d'"
%
slave_fd
)
except
OSError
:
# " An optional feature could not be imported " ... ?
raise
TestSkipped
,
"Pseudo-terminals (seemingly) not functional."
raise
TestSkipped
(
"Pseudo-terminals (seemingly) not functional."
)
self
.
assertTrue
(
os
.
isatty
(
slave_fd
),
'slave_fd is not a tty'
)
...
...
Lib/test/test_queue.py
View file @
3add4d78
...
...
@@ -87,17 +87,17 @@ class FailingQueue(Queue.Queue):
def
_put
(
self
,
item
):
if
self
.
fail_next_put
:
self
.
fail_next_put
=
False
raise
FailingQueueException
,
"You Lose"
raise
FailingQueueException
(
"You Lose"
)
return
Queue
.
Queue
.
_put
(
self
,
item
)
def
_get
(
self
):
if
self
.
fail_next_get
:
self
.
fail_next_get
=
False
raise
FailingQueueException
,
"You Lose"
raise
FailingQueueException
(
"You Lose"
)
return
Queue
.
Queue
.
_get
(
self
)
def
FailingQueueTest
(
q
):
if
not
q
.
empty
():
raise
RuntimeError
,
"Call this function with an empty queue"
raise
RuntimeError
(
"Call this function with an empty queue"
)
for
i
in
range
(
QUEUE_SIZE
-
1
):
q
.
put
(
i
)
# Test a failing non-blocking put.
...
...
@@ -178,7 +178,7 @@ def FailingQueueTest(q):
def
SimpleQueueTest
(
q
):
if
not
q
.
empty
():
raise
RuntimeError
,
"Call this function with an empty queue"
raise
RuntimeError
(
"Call this function with an empty queue"
)
# I guess we better check things actually queue correctly a little :)
q
.
put
(
111
)
q
.
put
(
222
)
...
...
Lib/test/test_re.py
View file @
3add4d78
...
...
@@ -612,7 +612,7 @@ def run_re_tests():
elif len(t) == 3:
pattern, s, outcome = t
else:
raise ValueError
,
('Test tuples should have 3 or 5 fields', t)
raise ValueError('Test tuples should have 3 or 5 fields', t)
try:
obj = re.compile(pattern)
...
...
Lib/test/test_richcmp.py
View file @
3add4d78
...
...
@@ -29,7 +29,7 @@ class Number:
return
self
.
x
>=
other
def
__cmp__
(
self
,
other
):
raise
test_support
.
TestFailed
,
"Number.__cmp__() should not be called"
raise
test_support
.
TestFailed
(
"Number.__cmp__() should not be called"
)
def
__repr__
(
self
):
return
"Number(%r)"
%
(
self
.
x
,
)
...
...
@@ -49,13 +49,13 @@ class Vector:
self
.
data
[
i
]
=
v
def
__hash__
(
self
):
raise
TypeError
,
"Vectors cannot be hashed"
raise
TypeError
(
"Vectors cannot be hashed"
)
def
__bool__
(
self
):
raise
TypeError
,
"Vectors cannot be used in Boolean contexts"
raise
TypeError
(
"Vectors cannot be used in Boolean contexts"
)
def
__cmp__
(
self
,
other
):
raise
test_support
.
TestFailed
,
"Vector.__cmp__() should not be called"
raise
test_support
.
TestFailed
(
"Vector.__cmp__() should not be called"
)
def
__repr__
(
self
):
return
"Vector(%r)"
%
(
self
.
data
,
)
...
...
@@ -82,7 +82,7 @@ class Vector:
if
isinstance
(
other
,
Vector
):
other
=
other
.
data
if
len
(
self
.
data
)
!=
len
(
other
):
raise
ValueError
,
"Cannot compare vectors of different length"
raise
ValueError
(
"Cannot compare vectors of different length"
)
return
other
opmap
=
{
...
...
@@ -196,10 +196,10 @@ class MiscTest(unittest.TestCase):
def
__lt__
(
self
,
other
):
return
0
def
__gt__
(
self
,
other
):
return
0
def
__eq__
(
self
,
other
):
return
0
def
__le__
(
self
,
other
):
raise
TestFailed
,
"This shouldn't happen"
def
__ge__
(
self
,
other
):
raise
TestFailed
,
"This shouldn't happen"
def
__ne__
(
self
,
other
):
raise
TestFailed
,
"This shouldn't happen"
def
__cmp__
(
self
,
other
):
raise
RuntimeError
,
"expected"
def
__le__
(
self
,
other
):
raise
TestFailed
(
"This shouldn't happen"
)
def
__ge__
(
self
,
other
):
raise
TestFailed
(
"This shouldn't happen"
)
def
__ne__
(
self
,
other
):
raise
TestFailed
(
"This shouldn't happen"
)
def
__cmp__
(
self
,
other
):
raise
RuntimeError
(
"expected"
)
a
=
Misb
()
b
=
Misb
()
self
.
assertEqual
(
a
<
b
,
0
)
...
...
Lib/test/test_scope.py
View file @
3add4d78
...
...
@@ -177,7 +177,7 @@ class ScopeTests(unittest.TestCase):
if x >= 0:
return fact(x)
else:
raise ValueError
, "
x
must
be
>=
0
"
raise ValueError
("
x
must
be
>=
0
")
self.assertEqual(f(6), 720)
...
...
Lib/test/test_socket.py
View file @
3add4d78
...
...
@@ -125,7 +125,7 @@ class ThreadableTest:
self
.
client_ready
.
set
()
self
.
clientSetUp
()
if
not
hasattr
(
test_func
,
'__call__'
):
raise
TypeError
,
"test_func must be a callable function"
raise
TypeError
(
"test_func must be a callable function"
)
try
:
test_func
()
except
Exception
as
strerror
:
...
...
@@ -133,7 +133,7 @@ class ThreadableTest:
self
.
clientTearDown
()
def
clientSetUp
(
self
):
raise
NotImplementedError
,
"clientSetUp must be implemented."
raise
NotImplementedError
(
"clientSetUp must be implemented."
)
def
clientTearDown
(
self
):
self
.
done
.
set
()
...
...
Lib/test/test_socketserver.py
View file @
3add4d78
...
...
@@ -45,7 +45,7 @@ def receive(sock, n, timeout=20):
if
sock
in
r
:
return
sock
.
recv
(
n
)
else
:
raise
RuntimeError
,
"timed out on %r"
%
(
sock
,
)
raise
RuntimeError
(
"timed out on %r"
%
(
sock
,)
)
def
testdgram
(
proto
,
addr
):
s
=
socket
.
socket
(
proto
,
socket
.
SOCK_DGRAM
)
...
...
Lib/test/test_struct.py
View file @
3add4d78
...
...
@@ -36,8 +36,8 @@ def simple_err(func, *args):
except
struct
.
error
:
pass
else
:
raise
TestFailed
,
"%s%s did not raise struct.error"
%
(
func
.
__name__
,
args
)
raise
TestFailed
(
"%s%s did not raise struct.error"
%
(
func
.
__name__
,
args
)
)
def
any_err
(
func
,
*
args
):
try
:
...
...
@@ -45,8 +45,8 @@ def any_err(func, *args):
except
(
struct
.
error
,
TypeError
):
pass
else
:
raise
TestFailed
,
"%s%s did not raise error"
%
(
func
.
__name__
,
args
)
raise
TestFailed
(
"%s%s did not raise error"
%
(
func
.
__name__
,
args
)
)
def
with_warning_restore
(
func
):
def
_with_warning_restore
(
*
args
,
**
kw
):
...
...
@@ -70,11 +70,11 @@ def deprecated_err(func, *args):
pass
except
DeprecationWarning
:
if
not
PY_STRUCT_OVERFLOW_MASKING
:
raise
TestFailed
,
"%s%s expected to raise struct.error"
%
(
func
.
__name__
,
args
)
raise
TestFailed
(
"%s%s expected to raise struct.error"
%
(
func
.
__name__
,
args
)
)
else
:
raise
TestFailed
,
"%s%s did not raise error"
%
(
func
.
__name__
,
args
)
raise
TestFailed
(
"%s%s did not raise error"
%
(
func
.
__name__
,
args
)
)
deprecated_err
=
with_warning_restore
(
deprecated_err
)
...
...
@@ -82,15 +82,15 @@ simple_err(struct.calcsize, 'Z')
sz
=
struct
.
calcsize
(
'i'
)
if
sz
*
3
!=
struct
.
calcsize
(
'iii'
):
raise
TestFailed
,
'inconsistent sizes'
raise
TestFailed
(
'inconsistent sizes'
)
fmt
=
'cbxxxxxxhhhhiillffdt'
fmt3
=
'3c3b18x12h6i6l6f3d3t'
sz
=
struct
.
calcsize
(
fmt
)
sz3
=
struct
.
calcsize
(
fmt3
)
if
sz
*
3
!=
sz3
:
raise
TestFailed
,
'inconsistent sizes (3*%r -> 3*%d = %d, %r -> %d)'
%
(
fmt
,
sz
,
3
*
sz
,
fmt3
,
sz3
)
raise
TestFailed
(
'inconsistent sizes (3*%r -> 3*%d = %d, %r -> %d)'
%
(
fmt
,
sz
,
3
*
sz
,
fmt3
,
sz3
)
)
simple_err
(
struct
.
pack
,
'iii'
,
3
)
simple_err
(
struct
.
pack
,
'i'
,
3
,
3
,
3
)
...
...
@@ -121,8 +121,8 @@ for prefix in ('', '@', '<', '>', '=', '!'):
int
(
100
*
fp
)
!=
int
(
100
*
f
)
or
int
(
100
*
dp
)
!=
int
(
100
*
d
)
or
tp
!=
t
):
# ^^^ calculate only to two decimal places
raise
TestFailed
,
"unpack/pack not transitive (%s, %s)"
%
(
str
(
format
),
str
((
cp
,
bp
,
hp
,
ip
,
lp
,
fp
,
dp
,
tp
)))
raise
TestFailed
(
"unpack/pack not transitive (%s, %s)"
%
(
str
(
format
),
str
((
cp
,
bp
,
hp
,
ip
,
lp
,
fp
,
dp
,
tp
)))
)
# Test some of the new features in detail
...
...
@@ -176,16 +176,16 @@ for fmt, arg, big, lil, asy in tests:
(
'='
+
fmt
,
ISBIGENDIAN
and
big
or
lil
)]:
res
=
struct
.
pack
(
xfmt
,
arg
)
if
res
!=
exp
:
raise
TestFailed
,
"pack(%r, %r) -> %r # expected %r"
%
(
fmt
,
arg
,
res
,
exp
)
raise
TestFailed
(
"pack(%r, %r) -> %r # expected %r"
%
(
fmt
,
arg
,
res
,
exp
)
)
n
=
struct
.
calcsize
(
xfmt
)
if
n
!=
len
(
res
):
raise
TestFailed
,
"calcsize(%r) -> %d # expected %d"
%
(
xfmt
,
n
,
len
(
res
))
raise
TestFailed
(
"calcsize(%r) -> %d # expected %d"
%
(
xfmt
,
n
,
len
(
res
))
)
rev
=
struct
.
unpack
(
xfmt
,
res
)[
0
]
if
rev
!=
arg
and
not
asy
:
raise
TestFailed
,
"unpack(%r, %r) -> (%r,) # expected (%r,)"
%
(
fmt
,
res
,
rev
,
arg
)
raise
TestFailed
(
"unpack(%r, %r) -> (%r,) # expected (%r,)"
%
(
fmt
,
res
,
rev
,
arg
)
)
###########################################################################
# Simple native q/Q tests.
...
...
Lib/test/test_thread.py
View file @
3add4d78
...
...
@@ -108,7 +108,7 @@ def task2(ident):
print
(
'
\
n
*** Barrier Test ***'
)
if
done
.
acquire
(
0
):
raise
ValueError
,
"'done' should have remained acquired"
raise
ValueError
(
"'done' should have remained acquired"
)
bar
=
barrier
(
numtasks
)
running
=
numtasks
for
i
in
range
(
numtasks
):
...
...
@@ -119,11 +119,11 @@ print('all tasks done')
# not all platforms support changing thread stack size
print
(
'
\
n
*** Changing thread stack size ***'
)
if
thread
.
stack_size
()
!=
0
:
raise
ValueError
,
"initial stack_size not 0"
raise
ValueError
(
"initial stack_size not 0"
)
thread
.
stack_size
(
0
)
if
thread
.
stack_size
()
!=
0
:
raise
ValueError
,
"stack_size not reset to default"
raise
ValueError
(
"stack_size not reset to default"
)
from
os
import
name
as
os_name
if
os_name
in
(
"nt"
,
"os2"
,
"posix"
):
...
...
@@ -143,7 +143,7 @@ if os_name in ("nt", "os2", "posix"):
for
tss
in
(
262144
,
0x100000
,
0
):
thread
.
stack_size
(
tss
)
if
failed
(
thread
.
stack_size
(),
tss
):
raise
ValueError
,
fail_msg
%
tss
raise
ValueError
(
fail_msg
%
tss
)
print
(
'successfully set stack_size(%d)'
%
tss
)
for
tss
in
(
262144
,
0x100000
):
...
...
Lib/test/test_threadsignals.py
View file @
3add4d78
...
...
@@ -8,7 +8,7 @@ import sys
from
test.test_support
import
run_unittest
,
TestSkipped
if
sys
.
platform
[:
3
]
in
(
'win'
,
'os2'
):
raise
TestSkipped
,
"Can't test signal on %s"
%
sys
.
platform
raise
TestSkipped
(
"Can't test signal on %s"
%
sys
.
platform
)
process_pid
=
os
.
getpid
()
signalled_all
=
thread
.
allocate_lock
()
...
...
Lib/test/test_trace.py
View file @
3add4d78
...
...
@@ -314,7 +314,7 @@ class RaisingTraceFuncTestCase(unittest.TestCase):
def
g
(
frame
,
why
,
extra
):
if
(
why
==
'line'
and
frame
.
f_lineno
==
f
.
__code__
.
co_firstlineno
+
2
):
raise
RuntimeError
,
"i am crashing"
raise
RuntimeError
(
"i am crashing"
)
return
g
sys
.
settrace
(
g
)
...
...
@@ -558,7 +558,7 @@ def no_jump_without_trace_function():
raise
else
:
# Something's wrong - the expected exception wasn't raised.
raise
RuntimeError
,
"Trace-function-less jump failed to fail"
raise
RuntimeError
(
"Trace-function-less jump failed to fail"
)
class
JumpTestCase
(
unittest
.
TestCase
):
...
...
Lib/test/test_traceback.py
View file @
3add4d78
...
...
@@ -15,7 +15,7 @@ class TracebackCases(unittest.TestCase):
except
exc
as
value
:
return
traceback
.
format_exception_only
(
exc
,
value
)
else
:
raise
ValueError
,
"call did not raise exception"
raise
ValueError
(
"call did not raise exception"
)
def
syntax_error_with_caret
(
self
):
compile
(
"def fact(x):
\
n
\
t
return x!
\
n
"
,
"?"
,
"exec"
)
...
...
Lib/test/test_unicode_file.py
View file @
3add4d78
...
...
@@ -25,7 +25,7 @@ if TESTFN_ENCODED.decode(TESTFN_ENCODING) != TESTFN_UNICODE:
TESTFN_ENCODED
=
TESTFN_UNICODE
.
encode
(
TESTFN_ENCODING
)
if
'?'
in
TESTFN_ENCODED
:
# MBCS will not report the error properly
raise
UnicodeError
,
"mbcs encoding problem"
raise
UnicodeError
(
"mbcs encoding problem"
)
except
(
UnicodeError
,
TypeError
):
raise
TestSkipped
(
"Cannot find a suitable filename"
)
...
...
Lib/test/test_univnewlines.py
View file @
3add4d78
...
...
@@ -5,8 +5,8 @@ import sys
from
test
import
test_support
if
not
hasattr
(
sys
.
stdin
,
'newlines'
):
raise
test_support
.
TestSkipped
,
\
"This Python does not have universal newline support"
raise
test_support
.
TestSkipped
(
"This Python does not have universal newline support"
)
FATX
=
'x'
*
(
2
**
14
)
...
...
Lib/test/test_wait3.py
View file @
3add4d78
...
...
@@ -9,12 +9,12 @@ from test.test_support import TestSkipped, run_unittest, reap_children
try
:
os
.
fork
except
AttributeError
:
raise
TestSkipped
,
"os.fork not defined -- skipping test_wait3"
raise
TestSkipped
(
"os.fork not defined -- skipping test_wait3"
)
try
:
os
.
wait3
except
AttributeError
:
raise
TestSkipped
,
"os.wait3 not defined -- skipping test_wait3"
raise
TestSkipped
(
"os.wait3 not defined -- skipping test_wait3"
)
class
Wait3Test
(
ForkWait
):
def
wait_impl
(
self
,
cpid
):
...
...
Lib/test/test_wait4.py
View file @
3add4d78
...
...
@@ -9,12 +9,12 @@ from test.test_support import TestSkipped, run_unittest, reap_children
try
:
os
.
fork
except
AttributeError
:
raise
TestSkipped
,
"os.fork not defined -- skipping test_wait4"
raise
TestSkipped
(
"os.fork not defined -- skipping test_wait4"
)
try
:
os
.
wait4
except
AttributeError
:
raise
TestSkipped
,
"os.wait4 not defined -- skipping test_wait4"
raise
TestSkipped
(
"os.wait4 not defined -- skipping test_wait4"
)
class
Wait4Test
(
ForkWait
):
def
wait_impl
(
self
,
cpid
):
...
...
Lib/test/test_wave.py
View file @
3add4d78
...
...
@@ -4,7 +4,7 @@ import wave
def
check
(
t
,
msg
=
None
):
if
not
t
:
raise
TestFailed
,
msg
raise
TestFailed
(
msg
)
nchannels
=
2
sampwidth
=
2
...
...
Lib/test/time_hashlib.py
View file @
3add4d78
...
...
@@ -6,7 +6,7 @@ import hashlib
def
creatorFunc
():
raise
RuntimeError
,
"eek, creatorFunc not overridden"
raise
RuntimeError
(
"eek, creatorFunc not overridden"
)
def
test_scaled_msg
(
scale
,
name
):
iterations
=
106201
/
scale
*
20
...
...
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