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