[Python-checkins] cpython (3.2): Fix Issue 15922: make howto/urllib2.rst doctests pass.
senthil.kumaran
python-checkins at python.org
Tue Oct 9 09:41:05 CEST 2012
http://hg.python.org/cpython/rev/a6f37d503878
changeset: 79611:a6f37d503878
branch: 3.2
parent: 79608:f41e6ef3392a
user: Senthil Kumaran <senthil at uthcode.com>
date: Tue Oct 09 00:37:09 2012 -0700
summary:
Fix Issue 15922: make howto/urllib2.rst doctests pass.
Patch by Chris Jerdonek. Address Ezio's review comment.
files:
Doc/howto/urllib2.rst | 29 ++++++++++++++---------------
1 files changed, 14 insertions(+), 15 deletions(-)
diff --git a/Doc/howto/urllib2.rst b/Doc/howto/urllib2.rst
--- a/Doc/howto/urllib2.rst
+++ b/Doc/howto/urllib2.rst
@@ -137,7 +137,7 @@
>>> data['location'] = 'Northampton'
>>> data['language'] = 'Python'
>>> url_values = urllib.parse.urlencode(data)
- >>> print(url_values)
+ >>> print(url_values) # The order may differ from below. #doctest: +SKIP
name=Somebody+Here&language=Python&location=Northampton
>>> url = 'http://www.example.com/example.cgi'
>>> full_url = url + '?' + url_values
@@ -207,9 +207,9 @@
>>> req = urllib.request.Request('http://www.pretend_server.org')
>>> try: urllib.request.urlopen(req)
- >>> except urllib.error.URLError as e:
- >>> print(e.reason)
- >>>
+ ... except urllib.error.URLError as e:
+ ... print(e.reason) #doctest: +SKIP
+ ...
(4, 'getaddrinfo failed')
@@ -315,18 +315,17 @@
>>> req = urllib.request.Request('http://www.python.org/fish.html')
>>> try:
- >>> urllib.request.urlopen(req)
- >>> except urllib.error.HTTPError as e:
- >>> print(e.code)
- >>> print(e.read())
- >>>
+ ... urllib.request.urlopen(req)
+ ... except urllib.error.HTTPError as e:
+ ... print(e.code)
+ ... print(e.read()) #doctest: +ELLIPSIS, +NORMALIZE_WHITESPACE
+ ...
404
- <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
- "http://www.w3.org/TR/html4/loose.dtd">
- <?xml-stylesheet href="./css/ht2html.css"
- type="text/css"?>
- <html><head><title>Error 404: File Not Found</title>
- ...... etc...
+ b'<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
+ "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">\n\n\n<html
+ ...
+ <title>Page Not Found</title>\n
+ ...
Wrapping it Up
--------------
--
Repository URL: http://hg.python.org/cpython
More information about the Python-checkins
mailing list