Skip to content

some tests will fail on macOS when have a system proxy such as test_urllib2_localnet test_urllib2net #140029

@yihong0618

Description

@yihong0618

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    OS-mactestsTests in the Lib/test dirtype-bugAn unexpected behavior, bug, or error

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions