fancidev/qtinter

tests #78 error

Closed this issue · 3 comments

Python-3.9-PySide6-macos-latest

Run python tests/asyncio_tests.py
  python tests/asyncio_tests.py
  shell: /bin/bash -e {0}
  env:
    pythonLocation: /Users/runner/hostedtoolcache/Python/3.9.14/x64
    PKG_CONFIG_PATH: /Users/runner/hostedtoolcache/Python/3.9.14/x64/lib/pkgconfig
    Python_ROOT_DIR: /Users/runner/hostedtoolcache/Python/3.9.14/x64
    Python2_ROOT_DIR: /Users/runner/hostedtoolcache/Python/3.9.14/x64
    Python3_ROOT_DIR: /Users/runner/hostedtoolcache/Python/3.9.14/x64
    QTINTERBINDING: PySide6
    PYTHONPATH: src

...

======================================================================
ERROR: test_sendfile_fallback_close_peer_in_the_middle_of_receiving (test.test_asyncio.test_sendfile.PollEventLoopTests)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/Users/runner/hostedtoolcache/Python/3.9.14/x64/lib/python3.9/test/test_asyncio/test_sendfile.py", line 482, in test_sendfile_fallback_close_peer_in_the_middle_of_receiving
    self.run_loop(
  File "/Users/runner/hostedtoolcache/Python/3.9.14/x64/lib/python3.9/test/test_asyncio/test_sendfile.py", line 131, in run_loop
    return self.loop.run_until_complete(coro)
  File "/Users/runner/hostedtoolcache/Python/3.9.14/x64/lib/python3.9/asyncio/base_events.py", line 647, in run_until_complete
    return future.result()
  File "/Users/runner/hostedtoolcache/Python/3.9.14/x64/lib/python3.9/asyncio/base_events.py", line 1171, in sendfile
    return await self._sendfile_fallback(transport, file,
  File "/Users/runner/hostedtoolcache/Python/3.9.14/x64/lib/python3.9/asyncio/base_events.py", line 1195, in _sendfile_fallback
    await proto.drain()
  File "/Users/runner/hostedtoolcache/Python/3.9.14/x64/lib/python3.9/asyncio/base_events.py", line 231, in drain
    await fut
  File "/Users/runner/hostedtoolcache/Python/3.9.14/x64/lib/python3.9/asyncio/selector_events.py", line 941, in _write_ready
    n = self._sock.send(self._buffer)
OSError: [Errno 41] Protocol wrong type for socket

----------------------------------------------------------------------
Ran 2218 tests in 83.910s

FAILED (errors=1, skipped=77, expected failures=1)
Error: Process completed with exit code 1.

tests #79 had the same error:

Python-3.9-PySide6-macos-latest

Run python tests/asyncio_tests.py
  python tests/asyncio_tests.py
  shell: /bin/bash -e {0}
  env:
    pythonLocation: /Users/runner/hostedtoolcache/Python/3.9.14/x64
    PKG_CONFIG_PATH: /Users/runner/hostedtoolcache/Python/3.9.14/x64/lib/pkgconfig
    Python_ROOT_DIR: /Users/runner/hostedtoolcache/Python/3.9.14/x64
    Python2_ROOT_DIR: /Users/runner/hostedtoolcache/Python/3.9.14/x64
    Python3_ROOT_DIR: /Users/runner/hostedtoolcache/Python/3.9.14/x64
    QTINTERBINDING: PySide6
    PYTHONPATH: src

...

======================================================================
ERROR: test_sendfile_fallback_close_peer_in_the_middle_of_receiving (test.test_asyncio.test_sendfile.PollEventLoopTests)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/Users/runner/hostedtoolcache/Python/3.9.14/x64/lib/python3.9/test/test_asyncio/test_sendfile.py", line 482, in test_sendfile_fallback_close_peer_in_the_middle_of_receiving
    self.run_loop(
  File "/Users/runner/hostedtoolcache/Python/3.9.14/x64/lib/python3.9/test/test_asyncio/test_sendfile.py", line 131, in run_loop
    return self.loop.run_until_complete(coro)
  File "/Users/runner/hostedtoolcache/Python/3.9.14/x64/lib/python3.9/asyncio/base_events.py", line 647, in run_until_complete
    return future.result()
  File "/Users/runner/hostedtoolcache/Python/3.9.14/x64/lib/python3.9/asyncio/base_events.py", line 1171, in sendfile
    return await self._sendfile_fallback(transport, file,
  File "/Users/runner/hostedtoolcache/Python/3.9.14/x64/lib/python3.9/asyncio/base_events.py", line 1195, in _sendfile_fallback
    await proto.drain()
  File "/Users/runner/hostedtoolcache/Python/3.9.14/x64/lib/python3.9/asyncio/base_events.py", line 231, in drain
    await fut
  File "/Users/runner/hostedtoolcache/Python/3.9.14/x64/lib/python3.9/asyncio/selector_events.py", line 941, in _write_ready
    n = self._sock.send(self._buffer)
OSError: [Errno 41] Protocol wrong type for socket

----------------------------------------------------------------------
Ran 2218 tests in 65.749s

FAILED (errors=1, skipped=77, expected failures=1)
Error: Process completed with exit code 1.

This appears to be related to a well-known 'bug' with macOS; see the links above.

It's not really a bug with macOS but rather wrong assumption of the return value of system calls. For example, this particular failed test case (test_sendfile_fallback_close_peer_in_the_middle_of_receiving) assumes writing to a closed socket raises ConnectionError, but in fact it may raise OSError on macOS.

I added a CI step to run python -m test.test_asyncio to detect potential similar race conditions in the bundled tests.

Closing this issue unless we find out other cause of the error.