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
d2f3857c
Commit
d2f3857c
authored
Jan 30, 2011
by
Georg Brandl
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
#10961: fix exception handling in new pydoc server code.
Patch by Ron Adam, reviewed by Eric Araujo.
parent
ce227e35
Changes
3
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
108 additions
and
99 deletions
+108
-99
Lib/pydoc.py
Lib/pydoc.py
+84
-75
Lib/test/test_pydoc.py
Lib/test/test_pydoc.py
+21
-24
Misc/NEWS
Misc/NEWS
+3
-0
No files found.
Lib/pydoc.py
View file @
d2f3857c
This diff is collapsed.
Click to expand it.
Lib/test/test_pydoc.py
View file @
d2f3857c
...
...
@@ -244,7 +244,7 @@ def get_html_title(text):
return
title
class
Py
D
ocDocTest
(
unittest
.
TestCase
):
class
Py
d
ocDocTest
(
unittest
.
TestCase
):
@
unittest
.
skipIf
(
sys
.
flags
.
optimize
>=
2
,
"Docstrings are omitted with -O2 and above"
)
...
...
@@ -392,7 +392,7 @@ class TestDescriptions(unittest.TestCase):
self
.
assertIn
(
expected
,
pydoc
.
render_doc
(
c
))
class
Py
D
ocServerTest
(
unittest
.
TestCase
):
class
Py
d
ocServerTest
(
unittest
.
TestCase
):
"""Tests for pydoc._start_server"""
def
test_server
(
self
):
...
...
@@ -415,34 +415,31 @@ class PyDocServerTest(unittest.TestCase):
self
.
assertEqual
(
serverthread
.
error
,
None
)
class
Py
D
ocUrlHandlerTest
(
unittest
.
TestCase
):
class
Py
d
ocUrlHandlerTest
(
unittest
.
TestCase
):
"""Tests for pydoc._url_handler"""
def
test_content_type_err
(
self
):
err
=
'Error: unknown content type '
f
=
pydoc
.
_url_handler
result
=
f
(
""
,
""
)
self
.
assertEqual
(
result
,
err
+
"''"
)
result
=
f
(
""
,
"foobar"
)
self
.
assertEqual
(
result
,
err
+
"'foobar'"
)
self
.
assertRaises
(
TypeError
,
f
,
'A'
,
''
)
self
.
assertRaises
(
TypeError
,
f
,
'B'
,
'foobar'
)
def
test_url_requests
(
self
):
# Test for the correct title in the html pages returned.
# This tests the different parts of the URL handler without
# getting too picky about the exact html.
requests
=
[
(
""
,
"Py
thon
: Index of Modules"
),
(
"get?key="
,
"Py
thon
: Index of Modules"
),
(
"index"
,
"Py
thon
: Index of Modules"
),
(
"topics"
,
"Py
thon
: Topics"
),
(
"keywords"
,
"Py
thon
: Keywords"
),
(
"pydoc"
,
"Py
thon
: module pydoc"
),
(
"get?key=pydoc"
,
"Py
thon
: module pydoc"
),
(
"search?key=pydoc"
,
"Py
thon
: Search Results"
),
(
"
def"
,
"Python
: KEYWORD def"
),
(
"
STRINGS"
,
"Python
: TOPIC STRINGS"
),
(
"foobar"
,
"Py
thon: Erro
r"
),
(
"getfile?key=foobar"
,
"Py
thon: Read Erro
r"
),
(
""
,
"Py
doc
: Index of Modules"
),
(
"get?key="
,
"Py
doc
: Index of Modules"
),
(
"index"
,
"Py
doc
: Index of Modules"
),
(
"topics"
,
"Py
doc
: Topics"
),
(
"keywords"
,
"Py
doc
: Keywords"
),
(
"pydoc"
,
"Py
doc
: module pydoc"
),
(
"get?key=pydoc"
,
"Py
doc
: module pydoc"
),
(
"search?key=pydoc"
,
"Py
doc
: Search Results"
),
(
"
topic?key=def"
,
"Pydoc
: KEYWORD def"
),
(
"
topic?key=STRINGS"
,
"Pydoc
: TOPIC STRINGS"
),
(
"foobar"
,
"Py
doc: Error - fooba
r"
),
(
"getfile?key=foobar"
,
"Py
doc: Error - getfile?key=fooba
r"
),
]
for
url
,
title
in
requests
:
...
...
@@ -451,7 +448,7 @@ class PyDocUrlHandlerTest(unittest.TestCase):
self
.
assertEqual
(
result
,
title
)
path
=
string
.
__file__
title
=
"Py
thon
: getfile "
+
path
title
=
"Py
doc
: getfile "
+
path
url
=
"getfile?key="
+
path
text
=
pydoc
.
_url_handler
(
url
,
"text/html"
)
result
=
get_html_title
(
text
)
...
...
@@ -459,10 +456,10 @@ class PyDocUrlHandlerTest(unittest.TestCase):
def
test_main
():
test
.
support
.
run_unittest
(
Py
D
ocDocTest
,
test
.
support
.
run_unittest
(
Py
d
ocDocTest
,
TestDescriptions
,
Py
D
ocServerTest
,
Py
D
ocUrlHandlerTest
,
Py
d
ocServerTest
,
Py
d
ocUrlHandlerTest
,
)
if
__name__
==
"__main__"
:
...
...
Misc/NEWS
View file @
d2f3857c
...
...
@@ -88,6 +88,9 @@ Library
- Issue #9509: argparse now properly handles IOErrors raised by
argparse.FileType.
- Issue #10961: The new pydoc server now better handles exceptions raised
during request handling.
Build
-----
...
...
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