415
415
self.assertEqual(serverthread.error, None)
418
class PyDocUrlHandlerTest(unittest.TestCase):
418
class PydocUrlHandlerTest(unittest.TestCase):
419
419
"""Tests for pydoc._url_handler"""
421
421
def test_content_type_err(self):
422
err = 'Error: unknown content type '
423
422
f = pydoc._url_handler
425
self.assertEqual(result, err + "''")
426
result = f("", "foobar")
427
self.assertEqual(result, err + "'foobar'")
423
self.assertRaises(TypeError, f, 'A', '')
424
self.assertRaises(TypeError, f, 'B', 'foobar')
429
426
def test_url_requests(self):
430
427
# Test for the correct title in the html pages returned.
431
428
# This tests the different parts of the URL handler without
432
429
# getting too picky about the exact html.
434
("", "Python: Index of Modules"),
435
("get?key=", "Python: Index of Modules"),
436
("index", "Python: Index of Modules"),
437
("topics", "Python: Topics"),
438
("keywords", "Python: Keywords"),
439
("pydoc", "Python: module pydoc"),
440
("get?key=pydoc", "Python: module pydoc"),
441
("search?key=pydoc", "Python: Search Results"),
442
("def", "Python: KEYWORD def"),
443
("STRINGS", "Python: TOPIC STRINGS"),
444
("foobar", "Python: Error"),
445
("getfile?key=foobar", "Python: Read Error"),
431
("", "Pydoc: Index of Modules"),
432
("get?key=", "Pydoc: Index of Modules"),
433
("index", "Pydoc: Index of Modules"),
434
("topics", "Pydoc: Topics"),
435
("keywords", "Pydoc: Keywords"),
436
("pydoc", "Pydoc: module pydoc"),
437
("get?key=pydoc", "Pydoc: module pydoc"),
438
("search?key=pydoc", "Pydoc: Search Results"),
439
("topic?key=def", "Pydoc: KEYWORD def"),
440
("topic?key=STRINGS", "Pydoc: TOPIC STRINGS"),
441
("foobar", "Pydoc: Error - foobar"),
442
("getfile?key=foobar", "Pydoc: Error - getfile?key=foobar"),
448
445
for url, title in requests: