blob: 92f79636cd0f9d1c2a97dda3b28d4a37cecb582e [file] [log] [blame]
Georg Brandlb533e262008-05-25 18:19:30 +00001import os
Nick Coghlan7bb30b72010-12-03 09:29:11 +00002import sys
Georg Brandlb533e262008-05-25 18:19:30 +00003import difflib
Georg Brandlb533e262008-05-25 18:19:30 +00004import inspect
Nick Coghlan7bb30b72010-12-03 09:29:11 +00005import pydoc
6import re
7import string
8import subprocess
Georg Brandlb533e262008-05-25 18:19:30 +00009import test.support
Nick Coghlan7bb30b72010-12-03 09:29:11 +000010import time
11import unittest
Brian Curtin49c284c2010-03-31 03:19:28 +000012import xml.etree
Georg Brandld80d5f42010-12-03 07:47:22 +000013import textwrap
14from io import StringIO
Raymond Hettinger1103d052011-03-25 14:15:24 -070015from collections import namedtuple
Benjamin Peterson0289b152009-06-28 17:22:03 +000016from contextlib import contextmanager
Georg Brandld80d5f42010-12-03 07:47:22 +000017from test.support import TESTFN, forget, rmtree, EnvironmentVarGuard, \
Raymond Hettinger1103d052011-03-25 14:15:24 -070018 reap_children, captured_output, captured_stdout
Georg Brandlb533e262008-05-25 18:19:30 +000019
20from test import pydoc_mod
21
Florent Xicluna085a6562010-03-06 14:04:16 +000022# Just in case sys.modules["test"] has the optional attribute __loader__.
23if hasattr(pydoc_mod, "__loader__"):
24 del pydoc_mod.__loader__
25
Barry Warsaw28a691b2010-04-17 00:19:56 +000026expected_text_pattern = """
Georg Brandlb533e262008-05-25 18:19:30 +000027NAME
28 test.pydoc_mod - This is a test module for test_pydoc
Georg Brandlb533e262008-05-25 18:19:30 +000029%s
30CLASSES
31 builtins.object
32 A
33 B
34\x20\x20\x20\x20
35 class A(builtins.object)
36 | Hello and goodbye
37 |\x20\x20
38 | Methods defined here:
39 |\x20\x20
40 | __init__()
41 | Wow, I have no function!
42 |\x20\x20
43 | ----------------------------------------------------------------------
44 | Data descriptors defined here:
45 |\x20\x20
46 | __dict__
47 | dictionary for instance variables (if defined)
48 |\x20\x20
49 | __weakref__
50 | list of weak references to the object (if defined)
51\x20\x20\x20\x20
52 class B(builtins.object)
53 | Data descriptors defined here:
54 |\x20\x20
55 | __dict__
56 | dictionary for instance variables (if defined)
57 |\x20\x20
58 | __weakref__
59 | list of weak references to the object (if defined)
60 |\x20\x20
61 | ----------------------------------------------------------------------
62 | Data and other attributes defined here:
63 |\x20\x20
64 | NO_MEANING = 'eggs'
65
66FUNCTIONS
67 doc_func()
68 This function solves all of the world's problems:
69 hunger
70 lack of Python
71 war
72\x20\x20\x20\x20
73 nodoc_func()
74
75DATA
Alexander Belopolskya47bbf52010-11-18 01:52:54 +000076 __xyz__ = 'X, Y and Z'
Georg Brandlb533e262008-05-25 18:19:30 +000077
78VERSION
79 1.2.3.4
80
81AUTHOR
82 Benjamin Peterson
83
84CREDITS
85 Nobody
Alexander Belopolskya47bbf52010-11-18 01:52:54 +000086
87FILE
88 %s
Georg Brandlb533e262008-05-25 18:19:30 +000089""".strip()
90
Barry Warsaw28a691b2010-04-17 00:19:56 +000091expected_html_pattern = """
Georg Brandlb533e262008-05-25 18:19:30 +000092<table width="100%%" cellspacing=0 cellpadding=2 border=0 summary="heading">
93<tr bgcolor="#7799ee">
94<td valign=bottom>&nbsp;<br>
95<font color="#ffffff" face="helvetica, arial">&nbsp;<br><big><big><strong><a href="test.html"><font color="#ffffff">test</font></a>.pydoc_mod</strong></big></big> (version 1.2.3.4)</font></td
96><td align=right valign=bottom
97><font color="#ffffff" face="helvetica, arial"><a href=".">index</a><br><a href="file:%s">%s</a>%s</font></td></tr></table>
98 <p><tt>This&nbsp;is&nbsp;a&nbsp;test&nbsp;module&nbsp;for&nbsp;test_pydoc</tt></p>
99<p>
100<table width="100%%" cellspacing=0 cellpadding=2 border=0 summary="section">
101<tr bgcolor="#ee77aa">
102<td colspan=3 valign=bottom>&nbsp;<br>
103<font color="#ffffff" face="helvetica, arial"><big><strong>Classes</strong></big></font></td></tr>
104\x20\x20\x20\x20
105<tr><td bgcolor="#ee77aa"><tt>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</tt></td><td>&nbsp;</td>
106<td width="100%%"><dl>
107<dt><font face="helvetica, arial"><a href="builtins.html#object">builtins.object</a>
108</font></dt><dd>
109<dl>
110<dt><font face="helvetica, arial"><a href="test.pydoc_mod.html#A">A</a>
111</font></dt><dt><font face="helvetica, arial"><a href="test.pydoc_mod.html#B">B</a>
112</font></dt></dl>
113</dd>
114</dl>
115 <p>
116<table width="100%%" cellspacing=0 cellpadding=2 border=0 summary="section">
117<tr bgcolor="#ffc8d8">
118<td colspan=3 valign=bottom>&nbsp;<br>
119<font color="#000000" face="helvetica, arial"><a name="A">class <strong>A</strong></a>(<a href="builtins.html#object">builtins.object</a>)</font></td></tr>
120\x20\x20\x20\x20
121<tr bgcolor="#ffc8d8"><td rowspan=2><tt>&nbsp;&nbsp;&nbsp;</tt></td>
122<td colspan=2><tt>Hello&nbsp;and&nbsp;goodbye<br>&nbsp;</tt></td></tr>
123<tr><td>&nbsp;</td>
124<td width="100%%">Methods defined here:<br>
125<dl><dt><a name="A-__init__"><strong>__init__</strong></a>()</dt><dd><tt>Wow,&nbsp;I&nbsp;have&nbsp;no&nbsp;function!</tt></dd></dl>
126
127<hr>
128Data descriptors defined here:<br>
129<dl><dt><strong>__dict__</strong></dt>
130<dd><tt>dictionary&nbsp;for&nbsp;instance&nbsp;variables&nbsp;(if&nbsp;defined)</tt></dd>
131</dl>
132<dl><dt><strong>__weakref__</strong></dt>
133<dd><tt>list&nbsp;of&nbsp;weak&nbsp;references&nbsp;to&nbsp;the&nbsp;object&nbsp;(if&nbsp;defined)</tt></dd>
134</dl>
135</td></tr></table> <p>
136<table width="100%%" cellspacing=0 cellpadding=2 border=0 summary="section">
137<tr bgcolor="#ffc8d8">
138<td colspan=3 valign=bottom>&nbsp;<br>
139<font color="#000000" face="helvetica, arial"><a name="B">class <strong>B</strong></a>(<a href="builtins.html#object">builtins.object</a>)</font></td></tr>
140\x20\x20\x20\x20
141<tr><td bgcolor="#ffc8d8"><tt>&nbsp;&nbsp;&nbsp;</tt></td><td>&nbsp;</td>
142<td width="100%%">Data descriptors defined here:<br>
143<dl><dt><strong>__dict__</strong></dt>
144<dd><tt>dictionary&nbsp;for&nbsp;instance&nbsp;variables&nbsp;(if&nbsp;defined)</tt></dd>
145</dl>
146<dl><dt><strong>__weakref__</strong></dt>
147<dd><tt>list&nbsp;of&nbsp;weak&nbsp;references&nbsp;to&nbsp;the&nbsp;object&nbsp;(if&nbsp;defined)</tt></dd>
148</dl>
149<hr>
150Data and other attributes defined here:<br>
151<dl><dt><strong>NO_MEANING</strong> = 'eggs'</dl>
152
153</td></tr></table></td></tr></table><p>
154<table width="100%%" cellspacing=0 cellpadding=2 border=0 summary="section">
155<tr bgcolor="#eeaa77">
156<td colspan=3 valign=bottom>&nbsp;<br>
157<font color="#ffffff" face="helvetica, arial"><big><strong>Functions</strong></big></font></td></tr>
158\x20\x20\x20\x20
159<tr><td bgcolor="#eeaa77"><tt>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</tt></td><td>&nbsp;</td>
160<td width="100%%"><dl><dt><a name="-doc_func"><strong>doc_func</strong></a>()</dt><dd><tt>This&nbsp;function&nbsp;solves&nbsp;all&nbsp;of&nbsp;the&nbsp;world's&nbsp;problems:<br>
161hunger<br>
162lack&nbsp;of&nbsp;Python<br>
163war</tt></dd></dl>
164 <dl><dt><a name="-nodoc_func"><strong>nodoc_func</strong></a>()</dt></dl>
165</td></tr></table><p>
166<table width="100%%" cellspacing=0 cellpadding=2 border=0 summary="section">
167<tr bgcolor="#55aa55">
168<td colspan=3 valign=bottom>&nbsp;<br>
169<font color="#ffffff" face="helvetica, arial"><big><strong>Data</strong></big></font></td></tr>
170\x20\x20\x20\x20
171<tr><td bgcolor="#55aa55"><tt>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</tt></td><td>&nbsp;</td>
Alexander Belopolskya47bbf52010-11-18 01:52:54 +0000172<td width="100%%"><strong>__xyz__</strong> = 'X, Y and Z'</td></tr></table><p>
Georg Brandlb533e262008-05-25 18:19:30 +0000173<table width="100%%" cellspacing=0 cellpadding=2 border=0 summary="section">
174<tr bgcolor="#7799ee">
175<td colspan=3 valign=bottom>&nbsp;<br>
176<font color="#ffffff" face="helvetica, arial"><big><strong>Author</strong></big></font></td></tr>
177\x20\x20\x20\x20
178<tr><td bgcolor="#7799ee"><tt>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</tt></td><td>&nbsp;</td>
179<td width="100%%">Benjamin&nbsp;Peterson</td></tr></table><p>
180<table width="100%%" cellspacing=0 cellpadding=2 border=0 summary="section">
181<tr bgcolor="#7799ee">
182<td colspan=3 valign=bottom>&nbsp;<br>
183<font color="#ffffff" face="helvetica, arial"><big><strong>Credits</strong></big></font></td></tr>
184\x20\x20\x20\x20
185<tr><td bgcolor="#7799ee"><tt>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</tt></td><td>&nbsp;</td>
186<td width="100%%">Nobody</td></tr></table>
Barry Warsaw28a691b2010-04-17 00:19:56 +0000187""".strip() # ' <- emacs turd
Georg Brandlb533e262008-05-25 18:19:30 +0000188
189
190# output pattern for missing module
191missing_pattern = "no Python documentation found for '%s'"
192
Benjamin Peterson0289b152009-06-28 17:22:03 +0000193# output pattern for module with bad imports
194badimport_pattern = "problem in %s - ImportError: No module named %s"
195
Georg Brandlb533e262008-05-25 18:19:30 +0000196def run_pydoc(module_name, *args):
197 """
198 Runs pydoc on the specified module. Returns the stripped
199 output of pydoc.
200 """
201 cmd = [sys.executable, pydoc.__file__, " ".join(args), module_name]
Antoine Pitrouaecd3b72009-10-30 21:45:40 +0000202 try:
203 output = subprocess.Popen(cmd, stdout=subprocess.PIPE).communicate()[0]
204 return output.strip()
205 finally:
206 reap_children()
Georg Brandlb533e262008-05-25 18:19:30 +0000207
208def get_pydoc_html(module):
209 "Returns pydoc generated output as html"
210 doc = pydoc.HTMLDoc()
211 output = doc.docmodule(module)
212 loc = doc.getdocloc(pydoc_mod) or ""
213 if loc:
214 loc = "<br><a href=\"" + loc + "\">Module Docs</a>"
215 return output.strip(), loc
216
217def get_pydoc_text(module):
218 "Returns pydoc generated output as text"
219 doc = pydoc.TextDoc()
220 loc = doc.getdocloc(pydoc_mod) or ""
221 if loc:
222 loc = "\nMODULE DOCS\n " + loc + "\n"
223
224 output = doc.docmodule(module)
225
Nick Coghlan7bb30b72010-12-03 09:29:11 +0000226 # clean up the extra text formatting that pydoc performs
Georg Brandlb533e262008-05-25 18:19:30 +0000227 patt = re.compile('\b.')
228 output = patt.sub('', output)
229 return output.strip(), loc
230
231def print_diffs(text1, text2):
232 "Prints unified diffs for two texts"
Nick Coghlan7bb30b72010-12-03 09:29:11 +0000233 # XXX now obsolete, use unittest built-in support
Georg Brandlb533e262008-05-25 18:19:30 +0000234 lines1 = text1.splitlines(True)
235 lines2 = text2.splitlines(True)
236 diffs = difflib.unified_diff(lines1, lines2, n=0, fromfile='expected',
237 tofile='got')
238 print('\n' + ''.join(diffs))
239
Nick Coghlan7bb30b72010-12-03 09:29:11 +0000240def get_html_title(text):
Nick Coghlanecace282010-12-03 16:08:46 +0000241 # Bit of hack, but good enough for test purposes
242 header, _, _ = text.partition("</head>")
243 _, _, title = header.partition("<title>")
244 title, _, _ = title.partition("</title>")
Nick Coghlan7bb30b72010-12-03 09:29:11 +0000245 return title
246
Georg Brandlb533e262008-05-25 18:19:30 +0000247
Georg Brandld2f38572011-01-30 08:37:19 +0000248class PydocDocTest(unittest.TestCase):
Georg Brandlb533e262008-05-25 18:19:30 +0000249
R. David Murray378c0cf2010-02-24 01:46:21 +0000250 @unittest.skipIf(sys.flags.optimize >= 2,
251 "Docstrings are omitted with -O2 and above")
Georg Brandlb533e262008-05-25 18:19:30 +0000252 def test_html_doc(self):
253 result, doc_loc = get_pydoc_html(pydoc_mod)
254 mod_file = inspect.getabsfile(pydoc_mod)
Benjamin Petersonc5e94642008-06-14 23:04:46 +0000255 if sys.platform == 'win32':
256 import nturl2path
257 mod_url = nturl2path.pathname2url(mod_file)
258 else:
259 mod_url = mod_file
260 expected_html = expected_html_pattern % (mod_url, mod_file, doc_loc)
Georg Brandlb533e262008-05-25 18:19:30 +0000261 if result != expected_html:
262 print_diffs(expected_html, result)
263 self.fail("outputs are not equal, see diff above")
264
R. David Murray378c0cf2010-02-24 01:46:21 +0000265 @unittest.skipIf(sys.flags.optimize >= 2,
266 "Docstrings are omitted with -O2 and above")
Georg Brandlb533e262008-05-25 18:19:30 +0000267 def test_text_doc(self):
268 result, doc_loc = get_pydoc_text(pydoc_mod)
269 expected_text = expected_text_pattern % \
Alexander Belopolskya47bbf52010-11-18 01:52:54 +0000270 (doc_loc, inspect.getabsfile(pydoc_mod))
Georg Brandlb533e262008-05-25 18:19:30 +0000271 if result != expected_text:
272 print_diffs(expected_text, result)
273 self.fail("outputs are not equal, see diff above")
274
Brian Curtin49c284c2010-03-31 03:19:28 +0000275 def test_issue8225(self):
276 # Test issue8225 to ensure no doc link appears for xml.etree
277 result, doc_loc = get_pydoc_text(xml.etree)
278 self.assertEqual(doc_loc, "", "MODULE DOCS incorrectly includes a link")
279
Georg Brandlb533e262008-05-25 18:19:30 +0000280 def test_not_here(self):
281 missing_module = "test.i_am_not_here"
282 result = str(run_pydoc(missing_module), 'ascii')
283 expected = missing_pattern % missing_module
284 self.assertEqual(expected, result,
285 "documentation for missing module found")
286
Benjamin Peterson0289b152009-06-28 17:22:03 +0000287 def test_badimport(self):
288 # This tests the fix for issue 5230, where if pydoc found the module
289 # but the module had an internal import error pydoc would report no doc
290 # found.
291 modname = 'testmod_xyzzy'
292 testpairs = (
293 ('i_am_not_here', 'i_am_not_here'),
294 ('test.i_am_not_here_either', 'i_am_not_here_either'),
295 ('test.i_am_not_here.neither_am_i', 'i_am_not_here.neither_am_i'),
Barry Warsaw28a691b2010-04-17 00:19:56 +0000296 ('i_am_not_here.{}'.format(modname),
297 'i_am_not_here.{}'.format(modname)),
Benjamin Peterson0289b152009-06-28 17:22:03 +0000298 ('test.{}'.format(modname), modname),
299 )
300
301 @contextmanager
302 def newdirinpath(dir):
303 os.mkdir(dir)
304 sys.path.insert(0, dir)
305 yield
306 sys.path.pop(0)
307 rmtree(dir)
308
309 with newdirinpath(TESTFN), EnvironmentVarGuard() as env:
310 env['PYTHONPATH'] = TESTFN
311 fullmodname = os.path.join(TESTFN, modname)
312 sourcefn = fullmodname + os.extsep + "py"
313 for importstring, expectedinmsg in testpairs:
Barry Warsaw28a691b2010-04-17 00:19:56 +0000314 with open(sourcefn, 'w') as f:
315 f.write("import {}\n".format(importstring))
Benjamin Peterson0289b152009-06-28 17:22:03 +0000316 try:
317 result = run_pydoc(modname).decode("ascii")
318 finally:
319 forget(modname)
320 expected = badimport_pattern % (modname, expectedinmsg)
321 self.assertEqual(expected, result)
322
R. David Murray1f1b9d32009-05-27 20:56:59 +0000323 def test_input_strip(self):
324 missing_module = " test.i_am_not_here "
325 result = str(run_pydoc(missing_module), 'ascii')
326 expected = missing_pattern % missing_module.strip()
327 self.assertEqual(expected, result)
328
Ezio Melotti412c95a2010-02-16 23:31:04 +0000329 def test_stripid(self):
330 # test with strings, other implementations might have different repr()
331 stripid = pydoc.stripid
332 # strip the id
333 self.assertEqual(stripid('<function stripid at 0x88dcee4>'),
334 '<function stripid>')
335 self.assertEqual(stripid('<function stripid at 0x01F65390>'),
336 '<function stripid>')
337 # nothing to strip, return the same text
338 self.assertEqual(stripid('42'), '42')
339 self.assertEqual(stripid("<type 'exceptions.Exception'>"),
340 "<type 'exceptions.Exception'>")
341
Georg Brandld80d5f42010-12-03 07:47:22 +0000342 @unittest.skipIf(sys.flags.optimize >= 2,
343 'Docstrings are omitted with -O2 and above')
344 def test_help_output_redirect(self):
345 # issue 940286, if output is set in Helper, then all output from
346 # Helper.help should be redirected
347 old_pattern = expected_text_pattern
348 getpager_old = pydoc.getpager
349 getpager_new = lambda: (lambda x: x)
350 self.maxDiff = None
351
352 buf = StringIO()
353 helper = pydoc.Helper(output=buf)
354 unused, doc_loc = get_pydoc_text(pydoc_mod)
355 module = "test.pydoc_mod"
356 help_header = """
357 Help on module test.pydoc_mod in test:
358
359 """.lstrip()
360 help_header = textwrap.dedent(help_header)
361 expected_help_pattern = help_header + expected_text_pattern
362
363 pydoc.getpager = getpager_new
364 try:
365 with captured_output('stdout') as output, \
366 captured_output('stderr') as err:
367 helper.help(module)
368 result = buf.getvalue().strip()
369 expected_text = expected_help_pattern % \
370 (doc_loc, inspect.getabsfile(pydoc_mod))
371 self.assertEqual('', output.getvalue())
372 self.assertEqual('', err.getvalue())
373 self.assertEqual(expected_text, result)
374 finally:
375 pydoc.getpager = getpager_old
376
Raymond Hettinger1103d052011-03-25 14:15:24 -0700377 def test_namedtuple_public_underscore(self):
378 NT = namedtuple('NT', ['abc', 'def'], rename=True)
379 with captured_stdout() as help_io:
380 help(NT)
381 helptext = help_io.getvalue()
382 self.assertIn('_1', helptext)
383 self.assertIn('_replace', helptext)
384 self.assertIn('_asdict', helptext)
385
Georg Brandlb533e262008-05-25 18:19:30 +0000386
387class TestDescriptions(unittest.TestCase):
388
389 def test_module(self):
390 # Check that pydocfodder module can be described
391 from test import pydocfodder
392 doc = pydoc.render_doc(pydocfodder)
Benjamin Peterson577473f2010-01-19 00:09:57 +0000393 self.assertIn("pydocfodder", doc)
Georg Brandlb533e262008-05-25 18:19:30 +0000394
Georg Brandlb533e262008-05-25 18:19:30 +0000395 def test_class(self):
Nick Coghlan7bb30b72010-12-03 09:29:11 +0000396 class C: "New-style class"
Georg Brandlb533e262008-05-25 18:19:30 +0000397 c = C()
398
399 self.assertEqual(pydoc.describe(C), 'class C')
400 self.assertEqual(pydoc.describe(c), 'C')
401 expected = 'C in module %s object' % __name__
Benjamin Peterson577473f2010-01-19 00:09:57 +0000402 self.assertIn(expected, pydoc.render_doc(c))
Georg Brandlb533e262008-05-25 18:19:30 +0000403
404
Georg Brandld2f38572011-01-30 08:37:19 +0000405class PydocServerTest(unittest.TestCase):
Nick Coghlan7bb30b72010-12-03 09:29:11 +0000406 """Tests for pydoc._start_server"""
407
408 def test_server(self):
409
410 # Minimal test that starts the server, then stops it.
411 def my_url_handler(url, content_type):
412 text = 'the URL sent was: (%s, %s)' % (url, content_type)
413 return text
414
415 serverthread = pydoc._start_server(my_url_handler, port=0)
416 starttime = time.time()
417 timeout = 1 #seconds
418
419 while serverthread.serving:
420 time.sleep(.01)
421 if serverthread.serving and time.time() - starttime > timeout:
422 serverthread.stop()
423 break
424
425 self.assertEqual(serverthread.error, None)
426
427
Georg Brandld2f38572011-01-30 08:37:19 +0000428class PydocUrlHandlerTest(unittest.TestCase):
Nick Coghlan7bb30b72010-12-03 09:29:11 +0000429 """Tests for pydoc._url_handler"""
430
431 def test_content_type_err(self):
Nick Coghlan7bb30b72010-12-03 09:29:11 +0000432 f = pydoc._url_handler
Georg Brandld2f38572011-01-30 08:37:19 +0000433 self.assertRaises(TypeError, f, 'A', '')
434 self.assertRaises(TypeError, f, 'B', 'foobar')
Nick Coghlan7bb30b72010-12-03 09:29:11 +0000435
436 def test_url_requests(self):
437 # Test for the correct title in the html pages returned.
438 # This tests the different parts of the URL handler without
439 # getting too picky about the exact html.
440 requests = [
Georg Brandld2f38572011-01-30 08:37:19 +0000441 ("", "Pydoc: Index of Modules"),
442 ("get?key=", "Pydoc: Index of Modules"),
443 ("index", "Pydoc: Index of Modules"),
444 ("topics", "Pydoc: Topics"),
445 ("keywords", "Pydoc: Keywords"),
446 ("pydoc", "Pydoc: module pydoc"),
447 ("get?key=pydoc", "Pydoc: module pydoc"),
448 ("search?key=pydoc", "Pydoc: Search Results"),
449 ("topic?key=def", "Pydoc: KEYWORD def"),
450 ("topic?key=STRINGS", "Pydoc: TOPIC STRINGS"),
451 ("foobar", "Pydoc: Error - foobar"),
452 ("getfile?key=foobar", "Pydoc: Error - getfile?key=foobar"),
Nick Coghlan7bb30b72010-12-03 09:29:11 +0000453 ]
454
455 for url, title in requests:
456 text = pydoc._url_handler(url, "text/html")
457 result = get_html_title(text)
458 self.assertEqual(result, title)
459
460 path = string.__file__
Georg Brandld2f38572011-01-30 08:37:19 +0000461 title = "Pydoc: getfile " + path
Nick Coghlan7bb30b72010-12-03 09:29:11 +0000462 url = "getfile?key=" + path
463 text = pydoc._url_handler(url, "text/html")
464 result = get_html_title(text)
465 self.assertEqual(result, title)
466
467
Georg Brandlb533e262008-05-25 18:19:30 +0000468def test_main():
Georg Brandld2f38572011-01-30 08:37:19 +0000469 test.support.run_unittest(PydocDocTest,
Nick Coghlan7bb30b72010-12-03 09:29:11 +0000470 TestDescriptions,
Georg Brandld2f38572011-01-30 08:37:19 +0000471 PydocServerTest,
472 PydocUrlHandlerTest,
Nick Coghlan7bb30b72010-12-03 09:29:11 +0000473 )
Georg Brandlb533e262008-05-25 18:19:30 +0000474
475if __name__ == "__main__":
476 test_main()