Skip to content

Commit 800a2d5

Browse files
fixing test failures and lint errors
Signed-off-by: grantlouisherman <grantlouisherman041@gmail.com>
1 parent 0679bcb commit 800a2d5

1 file changed

Lines changed: 13 additions & 13 deletions

File tree

Lib/test/test_asyncio/test_sendfile.py

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -227,34 +227,33 @@ def test_sock_sendfile_zero_size(self):
227227

228228
self.assertEqual(ret, 0)
229229
self.assertEqual(self.file.tell(), 0)
230+
230231
def check_sock_sendfile_offset(self, data, offset, force_fallback=False):
231232
sock, proto = self.prepare_socksendfile()
232233
with tempfile.TemporaryFile() as f:
233234
f.write(data)
234235
f.flush()
235236
self.assertEqual(f.tell(), len(data))
236237

237-
if force_fallback:
238-
async def _sock_sendfile_fail(sock, file, offset, count):
239-
raise asyncio.exceptions.SendfileNotAvailableError()
240-
with support.swap_attr(self.loop, '_sock_sendfile_native', _sock_sendfile_fail):
238+
if force_fallback:
239+
async def _sock_sendfile_fail(sock, file, offset, count):
240+
raise asyncio.exceptions.SendfileNotAvailableError()
241+
with support.swap_attr(self.loop, '_sock_sendfile_native', _sock_sendfile_fail):
242+
ret = self.run_loop(self.loop.sock_sendfile(sock, f, offset, None))
243+
else:
241244
ret = self.run_loop(self.loop.sock_sendfile(sock, f, offset, None))
242-
else:
243-
ret = self.run_loop(self.loop.sock_sendfile(sock, f, offset, None))
244-
245-
self.assertEqual(f.tell(), len(data))
246-
247-
sock.close()
248-
self.run_loop(proto.wait_closed())
249-
250-
self.assertEqual(ret, len(data) - offset)
245+
self.assertEqual(f.tell(), len(data))
246+
sock.close()
247+
self.run_loop(proto.wait_closed())
248+
self.assertEqual(ret, len(data) - offset)
251249

252250
def test_sock_sendfile_offset(self):
253251
data = b'abcdef'
254252
for offset in (0, len(data) // 2, len(data)):
255253
for force_fallback in (False, True):
256254
with self.subTest(offset=offset, force_fallback=force_fallback):
257255
self.check_sock_sendfile_offset(data, offset, force_fallback)
256+
258257
def test_sock_sendfile_mix_with_regular_send(self):
259258
buf = b"mix_regular_send" * (4 * 1024) # 64 KiB
260259
sock, proto = self.prepare_socksendfile()
@@ -477,6 +476,7 @@ def test_sendfile_ssl_close_peer_after_receiving(self):
477476
self.assertEqual(ret, len(self.DATA))
478477
self.assertEqual(srv_proto.nbytes, len(self.DATA))
479478
self.assertEqual(srv_proto.data, self.DATA)
479+
self.assertEqual(self.file.tell(), len(self.DATA))
480480

481481
# On Solaris, lowering SO_RCVBUF on a TCP connection after it has been
482482
# established has no effect. Due to its age, this bug affects both Oracle

0 commit comments

Comments
 (0)