some tests will fail on macOS when have a system proxy such as test_urllib2_localnet test_urllib2net
未關閉
還沒有人認領這個 Issue。
OS-mac
tests
type-bug
- 主要語言
- Python
- 星號
- 77.2k
- 分支
- 36k
- PR 合併指標
- PR 指標待擷取
描述
Bug report
Bug description:
reproduce
make macOS a system proxy(not http_proxy https_proxy in env but at system)
➜ cpython git:(main) echo $http_proxy
➜ cpython git:(main) ./python.exe -c 'import urllib.request;print(urllib.request.getproxies())'
{'http': 'http://127.0.0.1:7897', 'https': 'http://127.0.0.1:7897', 'socks': 'http://127.0.0.1:7897'}
some of the error is because we only add no_proxy for env(in tests)
but macOS maybe have a system one
some bt
Ran 2 tests in 1.697s
FAILED (errors=2)
Warning -- Unraisable exception
Exception ignored while finalizing socket <socket.socket [closed] fd=3, family=2, type=1, proto=6>:
Traceback (most recent call last):
File "/Users/hyi/prs/cpython/Lib/test/libregrtest/single.py", line 165, in _load_run_test
regrtest_runner(result, test_func, runtests)
~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/Users/hyi/prs/cpython/Lib/test/libregrtest/single.py", line 118, in regrtest_runner
test_result = test_func()
File "/Users/hyi/prs/cpython/Lib/test/libregrtest/single.py", line 162, in test_func
return run_unittest(test_mod, runtests)
File "/Users/hyi/prs/cpython/Lib/test/libregrtest/single.py", line 42, in run_unittest
return _run_suite(tests)
File "/Users/hyi/prs/cpython/Lib/test/libregrtest/single.py", line 105, in _run_suite
raise support.TestFailedWithDetails(err, errors, failures, stats=stats)
test.support.TestFailedWithDetails: multiple errors occurred
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/Users/hyi/prs/cpython/Lib/test/support/__init__.py", line 847, in gc_collect
gc.collect()
~~~~~~~~~~^^
ResourceWarning: unclosed <socket.socket [closed] fd=3, family=2, type=1, proto=6>
Warning -- Unraisable exception
Exception ignored while calling deallocator <function _TemporaryFileCloser.__del__ at 0x105d07950>:
Traceback (most recent call last):
File "/Users/hyi/prs/cpython/Lib/test/libregrtest/single.py", line 165, in _load_run_test
regrtest_runner(result, test_func, runtests)
~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/Users/hyi/prs/cpython/Lib/test/libregrtest/single.py", line 118, in regrtest_runner
test_result = test_func()
File "/Users/hyi/prs/cpython/Lib/test/libregrtest/single.py", line 162, in test_func
return run_unittest(test_mod, runtests)
File "/Users/hyi/prs/cpython/Lib/test/libregrtest/single.py", line 42, in run_unittest
return _run_suite(tests)
File "/Users/hyi/prs/cpython/Lib/test/libregrtest/single.py", line 105, in _run_suite
raise support.TestFailedWithDetails(err, errors, failures, stats=stats)
test.support.TestFailedWithDetails: multiple errors occurred
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/Users/hyi/prs/cpython/Lib/tempfile.py", line 484, in __del__
_warnings.warn(self.warn_message, ResourceWarning)
~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
ResourceWarning: Implicitly cleaning up <HTTPError 404: 'Not Found'>
Warning -- Unraisable exception
Exception ignored while finalizing socket <socket.socket [closed] fd=4, family=2, type=1, proto=6>:
Traceback (most recent call last):
File "/Users/hyi/prs/cpython/Lib/test/libregrtest/single.py", line 165, in _load_run_test
regrtest_runner(result, test_func, runtests)
~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/Users/hyi/prs/cpython/Lib/test/libregrtest/single.py", line 118, in regrtest_runner
test_result = test_func()
File "/Users/hyi/prs/cpython/Lib/test/libregrtest/single.py", line 162, in test_func
return run_unittest(test_mod, runtests)
File "/Users/hyi/prs/cpython/Lib/test/libregrtest/single.py", line 42, in run_unittest
return _run_suite(tests)
File "/Users/hyi/prs/cpython/Lib/test/libregrtest/single.py", line 105, in _run_suite
raise support.TestFailedWithDetails(err, errors, failures, stats=stats)
test.support.TestFailedWithDetails: multiple errors occurred
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/Users/hyi/prs/cpython/Lib/test/support/__init__.py", line 847, in gc_collect
gc.collect()
~~~~~~~~~~^^
ResourceWarning: unclosed <socket.socket [closed] fd=4, family=2, type=1, proto=6>
Warning -- Unraisable exception
Exception ignored while calling deallocator <function _TemporaryFileCloser.__del__ at 0x105d07950>:
Traceback (most recent call last):
File "/Users/hyi/prs/cpython/Lib/test/libregrtest/single.py", line 165, in _load_run_test
regrtest_runner(result, test_func, runtests)
~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/Users/hyi/prs/cpython/Lib/test/libregrtest/single.py", line 118, in regrtest_runner
test_result = test_func()
File "/Users/hyi/prs/cpython/Lib/test/libregrtest/single.py", line 162, in test_func
return run_unittest(test_mod, runtests)
File "/Users/hyi/prs/cpython/Lib/test/libregrtest/single.py", line 42, in run_unittest
return _run_suite(tests)
File "/Users/hyi/prs/cpython/Lib/test/libregrtest/single.py", line 105, in _run_suite
raise support.TestFailedWithDetails(err, errors, failures, stats=stats)
test.support.TestFailedWithDetails: multiple errors occurred
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/Users/hyi/prs/cpython/Lib/tempfile.py", line 484, in __del__
_warnings.warn(self.warn_message, ResourceWarning)
~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
ResourceWarning: Implicitly cleaning up <HTTPError 404: 'Not Found'>
test test_urllib2net failed
0:02:07 load avg: 8.33 [5/5/5] test_urllibnet failed (env changed)
Re-running test_urllibnet in verbose mode
testURLread (test.test_urllibnet.URLTimeoutTest.testURLread) ... ok
test_bad_address (test.test_urllibnet.urlopenNetworkTests.test_bad_address) ... Warning -- Unraisable exception
Exception ignored while calling deallocator <function _TemporaryFileCloser.__del__ at 0x1030bb950>:
Traceback (most recent call last):
File "/Users/hyi/prs/cpython/Lib/tempfile.py", line 484, in __del__
_warnings.warn(self.warn_message, ResourceWarning)
~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
ResourceWarning: Implicitly cleaning up <HTTPError 502: 'Bad Gateway'>
ok
test_basic (test.test_urllibnet.urlopenNetworkTests.test_basic) ... ok
test_getcode (test.test_urllibnet.urlopenNetworkTests.test_getcode) ... ok
test_geturl (test.test_urllibnet.urlopenNetworkTests.test_geturl) ... ok
test_info (test.test_urllibnet.urlopenNetworkTests.test_info) ... ok
test_readlines (test.test_urllibnet.urlopenNetworkTests.test_readlines) ... ok
test_basic (test.test_urllibnet.urlretrieveNetworkTests.test_basic) ... ok
test_data_header (test.test_urllibnet.urlretrieveNetworkTests.test_data_header) ... ok
test_header (test.test_urllibnet.urlretrieveNetworkTests.test_header) ... ok
test_reporthook (test.test_urllibnet.urlretrieveNetworkTests.test_reporthook) ... ok
test_specified_path (test.test_urllibnet.urlretrieveNetworkTests.test_specified_path) ... ok
----------------------------------------------------------------------
Ran 12 tests in 7.103s
OK
4 tests failed again:
test_urllib test_urllib2 test_urllib2_localnet test_urllib2net
== Tests result: FAILURE then FAILURE ==
10 slowest tests:
- test_smtpnet: 1 min 10 sec
- test_signal: 48.5 sec
- test.test_multiprocessing_spawn.test_processes: 30.4 sec
- test.test_multiprocessing_forkserver.test_processes: 29.7 sec
- test_socket: 29.1 sec
- test_urllib2net: 28.4 sec
- test_xmlrpc: 27.3 sec
- test.test_concurrent_futures.test_process_pool: 26.3 sec
- test_logging: 25.0 sec
- test.test_io.test_signals: 24.4 sec
31 tests skipped:
test.test_asyncio.test_windows_events
test.test_asyncio.test_windows_utils test.test_gdb.test_backtrace
test.test_gdb.test_cfunction test.test_gdb.test_cfunction_full
test.test_gdb.test_misc test.test_gdb.test_pretty_print
test.test_multiprocessing_fork.test_manager
test.test_multiprocessing_fork.test_misc
test.test_multiprocessing_fork.test_processes
test.test_multiprocessing_fork.test_threads
test.test_os.test_windows test_android test_dbm_gnu test_devpoll
test_epoll test_free_threading test_idle test_launcher test_msvcrt
test_startfile test_tcl test_tkinter test_ttk test_ttk_textonly
test_turtle test_winapi test_winconsoleio test_winreg
test_winsound test_wmi
2 tests skipped (resource denied):
test_peg_generator test_zipfile64
1 test altered the execution environment (env changed):
test_urllibnet
5 re-run tests:
test_urllib test_urllib2 test_urllib2_localnet test_urllib2net
test_urllibnet
4 tests failed:
test_urllib test_urllib2 test_urllib2_localnet test_urllib2net
CPython versions tested on:
CPython main branch
Operating systems tested on:
macOS
Linked PRs
- gh-140144
貢獻指南
從這裡開始
- 先讀完整個 Issue,再讀專案的貢獻指南。
- 在 Issue 下留言說明你要接手 —— 這能避免兩個人做同樣的事。
- Fork 儲存庫,在一個分支上完成修改。
- 送出 Pull Request,並在描述裡引用這個 Issue 編號。
研究方向
先從名為 test_urllib2_localnet 和 test_urllib2net 的測試開始,然後檢查 urllib 測試如何設定 no_proxy,以及如何在 macOS 上取得系統代理伺服器。使用 macOS 系統代理伺服器進行重現,並執行列出的 urllib 測試;完成標準是這些測試通過且沒有與代理伺服器相關的失敗。
由索引模型根據 Issue 內容生成。
評估
- 技術堆疊
- python
- 領域
- networking
- Issue 類型
- 缺陷
- 難度
- 3/5
- 預估耗時
- 1-2 天
- 活躍度
- 停滯
- 描述清晰度
- 基本清楚
- 新手友好度
- 25/100