MCPcopy Index your code
hub / github.com/python/cpython / test_404

Method test_404

Lib/test/test_urllib2_localnet.py:536–549  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

534 self.assertEqual(data, expected_response)
535
536 def test_404(self):
537 expected_response = b"Bad bad bad..."
538 handler = self.start_server([(404, [], expected_response)])
539
540 try:
541 self.urlopen("http://localhost:%s/weeble" % handler.port)
542 except urllib.error.URLError as f:
543 data = f.read()
544 f.close()
545 else:
546 self.fail("404 should raise URLError")
547
548 self.assertEqual(data, expected_response)
549 self.assertEqual(handler.requests, ["/weeble"])
550
551 def test_200(self):
552 expected_response = b"pycon 2008..."

Callers

nothing calls this directly

Calls 6

start_serverMethod · 0.95
urlopenMethod · 0.95
readMethod · 0.45
closeMethod · 0.45
failMethod · 0.45
assertEqualMethod · 0.45

Tested by

no test coverage detected