Skip to content

Commit f092cda

Browse files
committed
fix SIM117 multiple-with-statements
Signed-off-by: Gaëtan Lehmann <[email protected]>
1 parent eaa765d commit f092cda

File tree

1 file changed

+9
-9
lines changed

1 file changed

+9
-9
lines changed

tests/security/test_tls.py

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -26,11 +26,11 @@ def test_tls_disabled(host: str, protocol_name: str):
2626

2727
with pytest.raises(ssl.SSLError):
2828
context = ssl.SSLContext(protocol)
29-
with socket.create_connection((str(host), PORT), timeout=10) as sock:
30-
with context.wrap_socket(sock, server_hostname=str(host)) as ssock:
31-
ssock.do_handshake()
32-
# If we reach this point, the protocol is enabled (test should fail)
33-
pytest.fail(f"Protocol {protocol} should be disabled but connection succeeded")
29+
with socket.create_connection((str(host), PORT), timeout=10) as sock, \
30+
context.wrap_socket(sock, server_hostname=str(host)) as ssock:
31+
ssock.do_handshake()
32+
# If we reach this point, the protocol is enabled (test should fail)
33+
pytest.fail(f"Protocol {protocol} should be disabled but connection succeeded")
3434

3535
@pytest.mark.parametrize("protocol_name", ["TLSv1.2"])
3636
def test_enabled(host: str, protocol_name: str):
@@ -48,9 +48,9 @@ def test_enabled(host: str, protocol_name: str):
4848

4949
try:
5050
context = ssl.SSLContext(protocol)
51-
with socket.create_connection((str(host), PORT), timeout=10) as sock:
52-
with context.wrap_socket(sock, server_hostname=str(host)) as ssock:
53-
ssock.do_handshake()
54-
assert ssock.version()
51+
with socket.create_connection((str(host), PORT), timeout=10) as sock, \
52+
context.wrap_socket(sock, server_hostname=str(host)) as ssock:
53+
ssock.do_handshake()
54+
assert ssock.version()
5555
except ssl.SSLError as e:
5656
pytest.fail(f"{protocol_name} should be enabled, but got SSLError: {e}")

0 commit comments

Comments
 (0)