python / python/cpython

Fix proxy usage in `test_urllib2_localnet` on macOS

未關閉
#137,942 2 則留言 0 個 reaction 已指派 0 人 在 GitHub 檢視

還沒有人認領這個 Issue。

OS-mac tests type-bug
主要語言
Python
星號
77.2k
分支
35.9k
PR 合併指標
PR 指標待擷取

描述

Bug description:

On macos run:

make test

Error:

...
ERROR: test_proxy_with_bad_password_raises_httperror (test.test_urllib2_localnet.ProxyAuthTests.test_proxy_with_bad_password_raises_httperror)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/Users/hyi/prs/cpython/Lib/urllib/request.py", line 1321, in do_open
    h.request(req.get_method(), req.selector, req.data, headers,
    ~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
              encode_chunked=req.has_header('Transfer-encoding'))
              ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/hyi/prs/cpython/Lib/http/client.py", line 1342, in request
    self._send_request(method, url, body, headers, encode_chunked)
    ~~~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/hyi/prs/cpython/Lib/http/client.py", line 1388, in _send_request
    self.endheaders(body, encode_chunked=encode_chunked)
    ~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/hyi/prs/cpython/Lib/http/client.py", line 1337, in endheaders
    self._send_output(message_body, encode_chunked=encode_chunked)
    ~~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/hyi/prs/cpython/Lib/http/client.py", line 1097, in _send_output
    self.send(msg)
    ~~~~~~~~~^^^^^
  File "/Users/hyi/prs/cpython/Lib/http/client.py", line 1041, in send
    self.connect()
    ~~~~~~~~~~~~^^
  File "/Users/hyi/prs/cpython/Lib/http/client.py", line 1007, in connect
    self.sock = self._create_connection(
                ~~~~~~~~~~~~~~~~~~~~~~~^
        (self.host,self.port), self.timeout, self.source_address)
        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/hyi/prs/cpython/Lib/socket.py", line 879, in create_connection
    raise exceptions[0]
  File "/Users/hyi/prs/cpython/Lib/socket.py", line 864, in create_connection
    sock.connect(sa)
    ~~~~~~~~~~~~^^^^
ConnectionRefusedError: [Errno 61] Connection refused

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/Users/hyi/prs/cpython/Lib/test/test_urllib2_localnet.py", line 368, in test_proxy_with_bad_password_raises_httperror
    self.opener.open(self.URL)
    ~~~~~~~~~~~~~~~~^^^^^^^^^^
  File "/Users/hyi/prs/cpython/Lib/urllib/request.py", line 487, in open
    response = self._open(req, data)
  File "/Users/hyi/prs/cpython/Lib/urllib/request.py", line 504, in _open
    result = self._call_chain(self.handle_open, protocol, protocol +
                              '_open', req)
  File "/Users/hyi/prs/cpython/Lib/urllib/request.py", line 464, in _call_chain
    result = func(*args)
  File "/Users/hyi/prs/cpython/Lib/urllib/request.py", line 1350, in http_open
    return self.do_open(http.client.HTTPConnection, req)
           ~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/hyi/prs/cpython/Lib/urllib/request.py", line 1324, in do_open
    raise URLError(err)
urllib.error.URLError: <urlopen error [Errno 61] Connection refused>

======================================================================
ERROR: test_proxy_with_no_password_raises_httperror (test.test_urllib2_localnet.ProxyAuthTests.test_proxy_with_no_password_raises_httperror)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/Users/hyi/prs/cpython/Lib/urllib/request.py", line 1321, in do_open
    h.request(req.get_method(), req.selector, req.data, headers,
    ~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
              encode_chunked=req.has_header('Transfer-encoding'))
              ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/hyi/prs/cpython/Lib/http/client.py", line 1342, in request
    self._send_request(method, url, body, headers, encode_chunked)
    ~~~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/hyi/prs/cpython/Lib/http/client.py", line 1388, in _send_request
    self.endheaders(body, encode_chunked=encode_chunked)
    ~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/hyi/prs/cpython/Lib/http/client.py", line 1337, in endheaders
    self._send_output(message_body, encode_chunked=encode_chunked)
    ~~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/hyi/prs/cpython/Lib/http/client.py", line 1097, in _send_output
    self.send(msg)
    ~~~~~~~~~^^^^^
  File "/Users/hyi/prs/cpython/Lib/http/client.py", line 1041, in send
    self.connect()
    ~~~~~~~~~~~~^^
  File "/Users/hyi/prs/cpython/Lib/http/client.py", line 1007, in connect
    self.sock = self._create_connection(
                ~~~~~~~~~~~~~~~~~~~~~~~^
        (self.host,self.port), self.timeout, self.source_address)
        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/hyi/prs/cpython/Lib/socket.py", line 879, in create_connection
    raise exceptions[0]
  File "/Users/hyi/prs/cpython/Lib/socket.py", line 864, in create_connection
    sock.connect(sa)
    ~~~~~~~~~~~~^^^^
ConnectionRefusedError: [Errno 61] Connection refused

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/Users/hyi/prs/cpython/Lib/test/test_urllib2_localnet.py", line 374, in test_proxy_with_no_password_raises_httperror
    self.opener.open(self.URL)
    ~~~~~~~~~~~~~~~~^^^^^^^^^^
  File "/Users/hyi/prs/cpython/Lib/urllib/request.py", line 487, in open
    response = self._open(req, data)
  File "/Users/hyi/prs/cpython/Lib/urllib/request.py", line 504, in _open
    result = self._call_chain(self.handle_open, protocol, protocol +
                              '_open', req)
  File "/Users/hyi/prs/cpython/Lib/urllib/request.py", line 464, in _call_chain
    result = func(*args)
  File "/Users/hyi/prs/cpython/Lib/urllib/request.py", line 1350, in http_open
    return self.do_open(http.client.HTTPConnection, req)
           ~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/hyi/prs/cpython/Lib/urllib/request.py", line 1324, in do_open
    raise URLError(err)
urllib.error.URLError: <urlopen error [Errno 61] Connection refused>

----------------------------------------------------------------------
Ran 3 tests in 0.311s

FAILED (errors=3)
test test_urllib2_localnet failed
CPython versions tested on:

CPython main branch

Operating systems tested on:

macOS

Linked PRs
  • gh-137943

貢獻指南

開啟貢獻指南

從這裡開始

  1. 先讀完整個 Issue,再讀專案的貢獻指南。
  2. 在 Issue 下留言說明你要接手 —— 這能避免兩個人做同樣的事。
  3. Fork 儲存庫,在一個分支上完成修改。
  4. 送出 Pull Request,並在描述裡引用這個 Issue 編號。

研究方向

從 Lib/test/test_urllib2_localnet.py 和報告中顯示的 ProxyAuthTests 失敗開始;檢查連結的 PR gh-137943,了解已經在進行的工作。確認執行 make test 時,代理測試能在 macOS 上成功完成。

由索引模型根據 Issue 內容生成。

評估

技術堆疊
python
領域
networking, testing-qa
Issue 類型
缺陷
難度
3/5
預估耗時
1-2 天
活躍度
停滯
描述清晰度
基本清楚
新手友好度
25/100

把新 issue 寄到你的電子郵件信箱

精選適合新手參與的 GitHub issue 摘要。