summaryrefslogtreecommitdiffstats
path: root/Lib/test/test_asyncio
diff options
context:
space:
mode:
authorfancidev <fancidev@gmail.com>2022-10-17 15:45:38 (GMT)
committerGitHub <noreply@github.com>2022-10-17 15:45:38 (GMT)
commit3e82ad05b18d004e4d01fdb643344d6a2bf11900 (patch)
tree0c0eaa7f597dab3eb21b92ae03b383bcee4e9321 /Lib/test/test_asyncio
parent72c10d3f1a6d42b70cc4b843295361db17cc0964 (diff)
downloadcpython-3e82ad05b18d004e4d01fdb643344d6a2bf11900.zip
cpython-3e82ad05b18d004e4d01fdb643344d6a2bf11900.tar.gz
cpython-3e82ad05b18d004e4d01fdb643344d6a2bf11900.tar.bz2
gh-98174: Handle EPROTOTYPE under macOS in test_sendfile_fallback_close_peer_in_the_middle_of_receiving (#98316)
Co-authored-by: Nikita Sobolev <mail@sobolevn.me>
Diffstat (limited to 'Lib/test/test_asyncio')
-rw-r--r--Lib/test/test_asyncio/test_sendfile.py14
1 files changed, 12 insertions, 2 deletions
diff --git a/Lib/test/test_asyncio/test_sendfile.py b/Lib/test/test_asyncio/test_sendfile.py
index a10504b..0198da2 100644
--- a/Lib/test/test_asyncio/test_sendfile.py
+++ b/Lib/test/test_asyncio/test_sendfile.py
@@ -1,6 +1,7 @@
"""Tests for sendfile functionality."""
import asyncio
+import errno
import os
import socket
import sys
@@ -484,8 +485,17 @@ class SendfileMixin(SendfileBase):
srv_proto, cli_proto = self.prepare_sendfile(close_after=1024)
with self.assertRaises(ConnectionError):
- self.run_loop(
- self.loop.sendfile(cli_proto.transport, self.file))
+ try:
+ self.run_loop(
+ self.loop.sendfile(cli_proto.transport, self.file))
+ except OSError as e:
+ # macOS may raise OSError of EPROTOTYPE when writing to a
+ # socket that is in the process of closing down.
+ if e.errno == errno.EPROTOTYPE and sys.platform == "darwin":
+ raise ConnectionError
+ else:
+ raise
+
self.run_loop(srv_proto.done)
self.assertTrue(1024 <= srv_proto.nbytes < len(self.DATA),