Skip to content

Commit 90992b8

Browse files
committed
small formatting fixes
1 parent 2cd9499 commit 90992b8

File tree

2 files changed

+22
-13
lines changed

2 files changed

+22
-13
lines changed

cheroot/makefile.py

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
import _pyio as io
55
import socket
66
import time
7+
78
from OpenSSL import SSL
89

910

@@ -34,8 +35,12 @@ def _flush_unlocked(self):
3435
n = self.raw.write(bytes(self._write_buf))
3536
except io.BlockingIOError as e:
3637
n = e.characters_writteni
37-
except (SSL.WantReadError,SSL.WantWriteError, SSL.WantX509LookupError) as e:
38-
# these errors require retries with the same data
38+
except (
39+
SSL.WantReadError,
40+
SSL.WantWriteError,
41+
SSL.WantX509LookupError,
42+
):
43+
# these errors require retries with the same data
3944
# if some data has already been written
4045
n = 0
4146
del self._write_buf[:n]

cheroot/test/test_ssl.py

Lines changed: 15 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
import threading
1111
import time
1212
import traceback
13+
from unittest import mock
1314

1415
import pytest
1516

@@ -40,7 +41,6 @@
4041
_get_conn_data,
4142
_probe_ipv6_sock,
4243
)
43-
from unittest import mock
4444
from ..wsgi import Gateway_10
4545

4646

@@ -627,38 +627,42 @@ def test_ssl_env( # noqa: C901 # FIXME
627627
),
628628
)
629629

630+
630631
class TestBufferedWriterSSLWantErrors:
631-
632+
"""Test SSL want error handling in BufferedWriter."""
633+
632634
def setup_method(self):
635+
"""Set up test fixtures with mock raw socket and BufferedWriter."""
633636
self.mock_raw = mock.Mock()
634637
self.mock_raw.closed = False
635638
self.writer = BufferedWriter(self.mock_raw)
636639

637640
def test_want_write_error_retry(self):
638641
"""Test that WantWriteError causes retry with same data."""
639-
test_data = b"hello world"
640-
642+
test_data = b'hello world'
643+
641644
self.mock_raw.write.side_effect = [
642645
OpenSSL.SSL.WantWriteError(),
643-
len(test_data)
646+
len(test_data),
644647
]
645-
648+
646649
result = self.writer.write(test_data)
647650
assert result == len(test_data)
648651
assert self.mock_raw.write.call_count == 2
649652

650653
def test_want_read_error_retry(self):
651654
"""Test that WantReadError causes retry with same data."""
652-
test_data = b"test data"
653-
655+
test_data = b'test data'
656+
654657
self.mock_raw.write.side_effect = [
655-
OpenSSL.SSL.WantReadError(),
656-
len(test_data)
658+
OpenSSL.SSL.WantReadError(),
659+
len(test_data),
657660
]
658-
661+
659662
result = self.writer.write(test_data)
660663
assert result == len(test_data)
661664

665+
662666
@pytest.mark.parametrize(
663667
'ip_addr',
664668
(

0 commit comments

Comments
 (0)