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
afed6ecf
Commit
afed6ecf
authored
Jul 15, 2011
by
Antoine Pitrou
Browse files
Options
Browse Files
Download
Plain Diff
Merge from 3.2
parents
e720725c
f7f54759
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
39 additions
and
27 deletions
+39
-27
Lib/test/support.py
Lib/test/support.py
+13
-6
Lib/test/test_pydoc.py
Lib/test/test_pydoc.py
+26
-21
No files found.
Lib/test/support.py
View file @
afed6ecf
...
@@ -24,9 +24,15 @@ import sysconfig
...
@@ -24,9 +24,15 @@ import sysconfig
import
logging.handlers
import
logging.handlers
try
:
try
:
import
_thread
import
_thread
,
threading
except
ImportError
:
except
ImportError
:
_thread
=
None
_thread
=
None
threading
=
None
try
:
import
multiprocessing.process
except
ImportError
:
multiprocessing
=
None
try
:
try
:
import
zlib
import
zlib
...
@@ -1358,19 +1364,20 @@ def modules_cleanup(oldmodules):
...
@@ -1358,19 +1364,20 @@ def modules_cleanup(oldmodules):
def
threading_setup
():
def
threading_setup
():
if
_thread
:
if
_thread
:
return
_thread
.
_count
(),
return
_thread
.
_count
(),
threading
.
_dangling
.
copy
()
else
:
else
:
return
1
,
return
1
,
()
def
threading_cleanup
(
nb_thread
s
):
def
threading_cleanup
(
*
original_value
s
):
if
not
_thread
:
if
not
_thread
:
return
return
_MAX_COUNT
=
10
_MAX_COUNT
=
10
for
count
in
range
(
_MAX_COUNT
):
for
count
in
range
(
_MAX_COUNT
):
n
=
_thread
.
_count
()
values
=
_thread
.
_count
(),
threading
.
_dangling
if
n
==
nb_thread
s
:
if
values
==
original_value
s
:
break
break
time
.
sleep
(
0.1
)
time
.
sleep
(
0.1
)
gc_collect
()
# XXX print a warning in case of failure?
# XXX print a warning in case of failure?
def
reap_threads
(
func
):
def
reap_threads
(
func
):
...
...
Lib/test/test_pydoc.py
View file @
afed6ecf
...
@@ -15,9 +15,12 @@ import textwrap
...
@@ -15,9 +15,12 @@ import textwrap
from
io
import
StringIO
from
io
import
StringIO
from
collections
import
namedtuple
from
collections
import
namedtuple
from
contextlib
import
contextmanager
from
contextlib
import
contextmanager
from
test.support
import
TESTFN
,
forget
,
rmtree
,
EnvironmentVarGuard
,
\
reap_children
,
captured_output
,
captured_stdout
,
unlink
from
test.script_helper
import
assert_python_ok
from
test.support
import
(
TESTFN
,
forget
,
rmtree
,
EnvironmentVarGuard
,
reap_children
,
reap_threads
,
captured_output
,
captured_stdout
,
unlink
)
from
test
import
pydoc_mod
from
test
import
pydoc_mod
try
:
try
:
...
@@ -199,17 +202,14 @@ missing_pattern = "no Python documentation found for '%s'"
...
@@ -199,17 +202,14 @@ missing_pattern = "no Python documentation found for '%s'"
# output pattern for module with bad imports
# output pattern for module with bad imports
badimport_pattern
=
"problem in %s - ImportError: No module named %r"
badimport_pattern
=
"problem in %s - ImportError: No module named %r"
def
run_pydoc
(
module_name
,
*
args
):
def
run_pydoc
(
module_name
,
*
args
,
**
env
):
"""
"""
Runs pydoc on the specified module. Returns the stripped
Runs pydoc on the specified module. Returns the stripped
output of pydoc.
output of pydoc.
"""
"""
cmd
=
[
sys
.
executable
,
pydoc
.
__file__
,
" "
.
join
(
args
),
module_name
]
args
=
args
+
(
module_name
,)
try
:
rc
,
out
,
err
=
assert_python_ok
(
pydoc
.
__file__
,
*
args
,
**
env
)
output
=
subprocess
.
Popen
(
cmd
,
stdout
=
subprocess
.
PIPE
).
communicate
()[
0
]
return
out
.
strip
()
return
output
.
strip
()
finally
:
reap_children
()
def
get_pydoc_html
(
module
):
def
get_pydoc_html
(
module
):
"Returns pydoc generated output as html"
"Returns pydoc generated output as html"
...
@@ -312,19 +312,20 @@ class PydocDocTest(unittest.TestCase):
...
@@ -312,19 +312,20 @@ class PydocDocTest(unittest.TestCase):
def
newdirinpath
(
dir
):
def
newdirinpath
(
dir
):
os
.
mkdir
(
dir
)
os
.
mkdir
(
dir
)
sys
.
path
.
insert
(
0
,
dir
)
sys
.
path
.
insert
(
0
,
dir
)
yield
try
:
sys
.
path
.
pop
(
0
)
yield
rmtree
(
dir
)
finally
:
sys
.
path
.
pop
(
0
)
rmtree
(
dir
)
with
newdirinpath
(
TESTFN
),
EnvironmentVarGuard
()
as
env
:
with
newdirinpath
(
TESTFN
):
env
[
'PYTHONPATH'
]
=
TESTFN
fullmodname
=
os
.
path
.
join
(
TESTFN
,
modname
)
fullmodname
=
os
.
path
.
join
(
TESTFN
,
modname
)
sourcefn
=
fullmodname
+
os
.
extsep
+
"py"
sourcefn
=
fullmodname
+
os
.
extsep
+
"py"
for
importstring
,
expectedinmsg
in
testpairs
:
for
importstring
,
expectedinmsg
in
testpairs
:
with
open
(
sourcefn
,
'w'
)
as
f
:
with
open
(
sourcefn
,
'w'
)
as
f
:
f
.
write
(
"import {}
\
n
"
.
format
(
importstring
))
f
.
write
(
"import {}
\
n
"
.
format
(
importstring
))
try
:
try
:
result
=
run_pydoc
(
modname
).
decode
(
"ascii"
)
result
=
run_pydoc
(
modname
,
PYTHONPATH
=
TESTFN
).
decode
(
"ascii"
)
finally
:
finally
:
forget
(
modname
)
forget
(
modname
)
expected
=
badimport_pattern
%
(
modname
,
expectedinmsg
)
expected
=
badimport_pattern
%
(
modname
,
expectedinmsg
)
...
@@ -494,13 +495,17 @@ class TestHelper(unittest.TestCase):
...
@@ -494,13 +495,17 @@ class TestHelper(unittest.TestCase):
self
.
assertEqual
(
sorted
(
pydoc
.
Helper
.
keywords
),
self
.
assertEqual
(
sorted
(
pydoc
.
Helper
.
keywords
),
sorted
(
keyword
.
kwlist
))
sorted
(
keyword
.
kwlist
))
@
reap_threads
def
test_main
():
def
test_main
():
test
.
support
.
run_unittest
(
PydocDocTest
,
try
:
TestDescriptions
,
test
.
support
.
run_unittest
(
PydocDocTest
,
PydocServerTest
,
TestDescriptions
,
PydocUrlHandlerTest
,
PydocServerTest
,
TestHelper
,
PydocUrlHandlerTest
,
)
TestHelper
,
)
finally
:
reap_children
()
if
__name__
==
"__main__"
:
if
__name__
==
"__main__"
:
test_main
()
test_main
()
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