GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — bpo-46648: Rewrite test_urllib2.test_issue16464() with a local HTTP s… · python/cpython@8e98175

File tree

Expand file treeCollapse file tree
Open diff view settings
Filter options
  • Lib/test
    • test_urllib2.py
    • test_urllib2_localnet.py
Expand file treeCollapse file tree
Open diff view settings
Collapse file

‎Lib/test/test_urllib2.py‎

Copy file name to clipboardExpand all lines: Lib/test/test_urllib2.py
-18Lines changed: 0 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1788,24 +1788,6 @@ class MyOtherHTTPHandler(urllib.request.HTTPHandler):
17881788
self.opener_has_handler(o, MyHTTPHandler)
17891789
self.opener_has_handler(o, MyOtherHTTPHandler)
17901790

1791-
@unittest.skipUnless(support.is_resource_enabled('network'),
1792-
'test requires network access')
1793-
# bpo-46648: test fails randomly with "http://www.example.com/" URL
1794-
@unittest.skipIf(True, "POST request to http://www.example.com/ fail randomly")
1795-
def test_issue16464(self):
1796-
with socket_helper.transient_internet("http://www.example.com/"):
1797-
opener = urllib.request.build_opener()
1798-
request = urllib.request.Request("http://www.example.com/")
1799-
self.assertEqual(None, request.data)
1800-
1801-
opener.open(request, "1".encode("us-ascii"))
1802-
self.assertEqual(b"1", request.data)
1803-
self.assertEqual("1", request.get_header("Content-length"))
1804-
1805-
opener.open(request, "1234567890".encode("us-ascii"))
1806-
self.assertEqual(b"1234567890", request.data)
1807-
self.assertEqual("10", request.get_header("Content-length"))
1808-
18091791
def test_HTTPError_interface(self):
18101792
"""
18111793
Issue 13211 reveals that HTTPError didn't implement the URLError
Collapse file

‎Lib/test/test_urllib2_localnet.py‎

Copy file name to clipboardExpand all lines: Lib/test/test_urllib2_localnet.py
+18Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -660,6 +660,24 @@ def test_line_iteration(self):
660660
(index, len(lines[index]), len(line)))
661661
self.assertEqual(index + 1, len(lines))
662662

663+
def test_issue16464(self):
664+
# See https://bugs.python.org/issue16464
665+
# and https://bugs.python.org/issue46648
666+
handler = self.start_server([
667+
(200, [], b'any'),
668+
(200, [], b'any'),
669+
])
670+
opener = urllib.request.build_opener()
671+
request = urllib.request.Request("http://localhost:%s" % handler.port)
672+
self.assertEqual(None, request.data)
673+
674+
opener.open(request, "1".encode("us-ascii"))
675+
self.assertEqual(b"1", request.data)
676+
self.assertEqual("1", request.get_header("Content-length"))
677+
678+
opener.open(request, "1234567890".encode("us-ascii"))
679+
self.assertEqual(b"1234567890", request.data)
680+
self.assertEqual("10", request.get_header("Content-length"))
663681

664682
def setUpModule():
665683
thread_info = threading_helper.threading_setup()

0 commit comments

Comments
0 (0)
You are visitor 01402520 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.