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
fce9233e
Commit
fce9233e
authored
Jun 01, 2011
by
Victor Stinner
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
test.support: add requires_mac_ver() function
Add also linux_version() to __all__.
parent
197a59f4
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
25 additions
and
4 deletions
+25
-4
Lib/test/support.py
Lib/test/support.py
+21
-1
Lib/test/test_math.py
Lib/test/test_math.py
+4
-3
No files found.
Lib/test/support.py
View file @
fce9233e
...
@@ -37,7 +37,8 @@ __all__ = [
...
@@ -37,7 +37,8 @@ __all__ = [
"Error"
,
"TestFailed"
,
"ResourceDenied"
,
"import_module"
,
"Error"
,
"TestFailed"
,
"ResourceDenied"
,
"import_module"
,
"verbose"
,
"use_resources"
,
"max_memuse"
,
"record_original_stdout"
,
"verbose"
,
"use_resources"
,
"max_memuse"
,
"record_original_stdout"
,
"get_original_stdout"
,
"unload"
,
"unlink"
,
"rmtree"
,
"forget"
,
"get_original_stdout"
,
"unload"
,
"unlink"
,
"rmtree"
,
"forget"
,
"is_resource_enabled"
,
"requires"
,
"find_unused_port"
,
"bind_port"
,
"is_resource_enabled"
,
"requires"
,
"linux_version"
,
"requires_mac_ver"
,
"find_unused_port"
,
"bind_port"
,
"IPV6_ENABLED"
,
"is_jython"
,
"TESTFN"
,
"HOST"
,
"SAVEDCWD"
,
"temp_cwd"
,
"IPV6_ENABLED"
,
"is_jython"
,
"TESTFN"
,
"HOST"
,
"SAVEDCWD"
,
"temp_cwd"
,
"findfile"
,
"sortdict"
,
"check_syntax_error"
,
"open_urlresource"
,
"findfile"
,
"sortdict"
,
"check_syntax_error"
,
"open_urlresource"
,
"check_warnings"
,
"CleanImport"
,
"EnvironmentVarGuard"
,
"TransientResource"
,
"check_warnings"
,
"CleanImport"
,
"EnvironmentVarGuard"
,
"TransientResource"
,
...
@@ -299,6 +300,25 @@ def linux_version():
...
@@ -299,6 +300,25 @@ def linux_version():
except
ValueError
:
except
ValueError
:
return
0
,
0
,
0
return
0
,
0
,
0
def
requires_mac_ver
(
*
min_version
):
"""Raise SkipTest if the OS is Mac OS X and the OS X version if less than
min_version.
For example, support.requires_linux_version(10, 5) raises SkipTest if the
version is less than 10.5.
"""
if
sys
.
platform
!=
'darwin'
:
return
version_txt
=
platform
.
mac_ver
()[
0
]
try
:
version
=
tuple
(
map
(
int
,
version_txt
.
split
(
'.'
)))
except
ValueError
:
return
if
version
<
min_version
:
min_version_txt
=
'.'
.
join
(
map
(
str
,
min_version
))
raise
unittest
.
SkipTest
(
"Mac OS X %s or higher required, not %s"
%
(
min_version_txt
,
version_txt
))
HOST
=
'localhost'
HOST
=
'localhost'
def
find_unused_port
(
family
=
socket
.
AF_INET
,
socktype
=
socket
.
SOCK_STREAM
):
def
find_unused_port
(
family
=
socket
.
AF_INET
,
socktype
=
socket
.
SOCK_STREAM
):
...
...
Lib/test/test_math.py
View file @
fce9233e
...
@@ -2,6 +2,7 @@
...
@@ -2,6 +2,7 @@
# XXXX Should not do tests around zero only
# XXXX Should not do tests around zero only
from
test.support
import
run_unittest
,
verbose
,
requires_IEEE_754
from
test.support
import
run_unittest
,
verbose
,
requires_IEEE_754
from
test
import
support
import
unittest
import
unittest
import
math
import
math
import
os
import
os
...
@@ -669,10 +670,10 @@ class MathTests(unittest.TestCase):
...
@@ -669,10 +670,10 @@ class MathTests(unittest.TestCase):
self
.
assertTrue
(
math
.
isnan
(
math
.
log2
(
NAN
)))
self
.
assertTrue
(
math
.
isnan
(
math
.
log2
(
NAN
)))
@
requires_IEEE_754
@
requires_IEEE_754
@
unittest
.
skipIf
(
sys
.
platform
==
'darwin'
and
platform
.
mac_ver
()[
0
].
startswith
(
'10.4.'
),
'Mac OS X Tiger log2() is not accurate enough'
)
def
testLog2Exact
(
self
):
def
testLog2Exact
(
self
):
# log2() is not accurate enough on Mac OS X Tiger (10.4)
support
.
requires_mac_ver
(
10
,
5
)
# Check that we get exact equality for log2 of powers of 2.
# Check that we get exact equality for log2 of powers of 2.
actual
=
[
math
.
log2
(
math
.
ldexp
(
1.0
,
n
))
for
n
in
range
(
-
1074
,
1024
)]
actual
=
[
math
.
log2
(
math
.
ldexp
(
1.0
,
n
))
for
n
in
range
(
-
1074
,
1024
)]
expected
=
[
float
(
n
)
for
n
in
range
(
-
1074
,
1024
)]
expected
=
[
float
(
n
)
for
n
in
range
(
-
1074
,
1024
)]
...
...
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