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
6cbba50a
Commit
6cbba50a
authored
Mar 10, 2004
by
Neil Schemenauer
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Make test_coercion.py less sensitive to platform fp quirks. Closes
SF bug #678265.
parent
66d31f8f
Changes
2
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
348 additions
and
333 deletions
+348
-333
Lib/test/output/test_coercion
Lib/test/output/test_coercion
+329
-329
Lib/test/test_coercion.py
Lib/test/test_coercion.py
+19
-4
No files found.
Lib/test/output/test_coercion
View file @
6cbba50a
This diff is collapsed.
Click to expand it.
Lib/test/test_coercion.py
View file @
6cbba50a
...
...
@@ -67,11 +67,26 @@ class MethodNumber:
candidates
=
[
2
,
4.0
,
2L
,
2
+
0j
,
[
1
],
(
2
,),
None
,
MethodNumber
(
1
),
CoerceNumber
(
2
)]
MethodNumber
(
2
),
CoerceNumber
(
2
)]
infix_binops
=
[
'+'
,
'-'
,
'*'
,
'/'
,
'**'
,
'%'
]
prefix_binops
=
[
'divmod'
]
def
format_float
(
value
):
if
abs
(
value
)
<
0.01
:
return
'0.0'
else
:
return
'%.1f'
%
value
# avoid testing platform fp quirks
def
format_result
(
value
):
if
isinstance
(
value
,
complex
):
return
'(%s + %sj)'
%
(
format_float
(
value
.
real
),
format_float
(
value
.
imag
))
elif
isinstance
(
value
,
float
):
return
format_float
(
value
)
return
str
(
value
)
def
do_infix_binops
():
for
a
in
candidates
:
for
b
in
candidates
:
...
...
@@ -83,7 +98,7 @@ def do_infix_binops():
error
=
sys
.
exc_info
()[:
2
]
print
'... %s'
%
error
[
0
]
else
:
print
'='
,
x
print
'='
,
format_result
(
x
)
try
:
z
=
copy
.
copy
(
a
)
except
copy
.
Error
:
...
...
@@ -95,7 +110,7 @@ def do_infix_binops():
error
=
sys
.
exc_info
()[:
2
]
print
'... %s'
%
error
[
0
]
else
:
print
'=>'
,
z
print
'=>'
,
format_result
(
z
)
def
do_prefix_binops
():
for
a
in
candidates
:
...
...
@@ -108,7 +123,7 @@ def do_prefix_binops():
error
=
sys
.
exc_info
()[:
2
]
print
'... %s'
%
error
[
0
]
else
:
print
'='
,
x
print
'='
,
format_result
(
x
)
warnings
.
filterwarnings
(
"ignore"
,
r'complex divmod\
(
\), // and % are deprecated'
,
...
...
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