1+ from __future__ import annotations
2+
13import os
24import re
35import sys
6+ from typing import TYPE_CHECKING
47
58import pytest
69
3336 check_two_way_stream ,
3437)
3538
39+ if TYPE_CHECKING :
40+ from _pytest .mark import MarkDecorator
41+
42+
3643# We have two different kinds of echo server fixtures we use for testing. The
3744# first is a real server written using the stdlib ssl module and blocking
3845# sockets. It runs in a thread and we talk to it over a real socketpair(), to
6168TRIO_TEST_1_CERT .configure_cert (SERVER_CTX )
6269
6370
71+ skip_on_broken_openssl : MarkDecorator = pytest .mark .skipif (
72+ sys .version_info < (3 , 8 ) and ssl .OPENSSL_VERSION_INFO [0 ] > 1 ,
73+ reason = "Python 3.7 does not work with OpenSSL versions higher than 1.X" ,
74+ )
75+
76+
6477# TLS 1.3 has a lot of changes from previous versions. So we want to run tests
6578# with both TLS 1.3, and TLS 1.2.
6679# "tls13" means that we're willing to negotiate TLS 1.3. Usually that's
@@ -809,6 +822,7 @@ async def test_send_all_empty_string(client_ctx):
809822 await s .aclose ()
810823
811824
825+ @skip_on_broken_openssl
812826@pytest .mark .parametrize ("https_compatible" , [False , True ])
813827async def test_SSLStream_generic (client_ctx , https_compatible ):
814828 async def stream_maker ():
@@ -1024,6 +1038,7 @@ async def test_ssl_bad_shutdown(client_ctx):
10241038 await server .aclose ()
10251039
10261040
1041+ @skip_on_broken_openssl
10271042async def test_ssl_bad_shutdown_but_its_ok (client_ctx ):
10281043 client , server = ssl_memory_stream_pair (
10291044 client_ctx ,
@@ -1088,6 +1103,7 @@ def close_hook():
10881103 assert transport_close_count == 1
10891104
10901105
1106+ @skip_on_broken_openssl
10911107async def test_ssl_https_compatibility_disagreement (client_ctx ):
10921108 client , server = ssl_memory_stream_pair (
10931109 client_ctx ,
@@ -1112,6 +1128,7 @@ async def receive_and_expect_error():
11121128 nursery .start_soon (receive_and_expect_error )
11131129
11141130
1131+ @skip_on_broken_openssl
11151132async def test_https_mode_eof_before_handshake (client_ctx ):
11161133 client , server = ssl_memory_stream_pair (
11171134 client_ctx ,
0 commit comments