Skip to content

Commit 5426f7b

Browse files
Remove conditionals and workarounds for Python interpreter versions 3.7 and older (#688)
1 parent 7565f31 commit 5426f7b

File tree

4 files changed

+1
-42
lines changed

4 files changed

+1
-42
lines changed

tests/streams/test_tls.py

+1-12
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22

33
import socket
44
import ssl
5-
import sys
65
from contextlib import ExitStack
76
from threading import Thread
87
from typing import ContextManager, NoReturn
@@ -26,10 +25,6 @@
2625
from anyio.streams.tls import TLSAttribute, TLSListener, TLSStream
2726

2827
pytestmark = pytest.mark.anyio
29-
skip_on_broken_openssl = pytest.mark.skipif(
30-
(ssl.OPENSSL_VERSION_INFO[0] > 1 and sys.version_info < (3, 8)),
31-
reason="Python 3.7 does not work with OpenSSL versions higher than 1.X",
32-
)
3328

3429

3530
class TestTLSStream:
@@ -193,7 +188,6 @@ def serve_sync() -> None:
193188
pytest.param(False, False, id="neither_standard"),
194189
],
195190
)
196-
@skip_on_broken_openssl
197191
async def test_ragged_eofs(
198192
self,
199193
server_context: ssl.SSLContext,
@@ -250,7 +244,6 @@ def serve_sync() -> None:
250244
else:
251245
assert server_exc is None
252246

253-
@skip_on_broken_openssl
254247
async def test_ragged_eof_on_receive(
255248
self, server_context: ssl.SSLContext, client_context: ssl.SSLContext
256249
) -> None:
@@ -350,10 +343,7 @@ def serve_sync() -> None:
350343
ca.configure_trust(client_context)
351344
if force_tlsv12:
352345
expected_pattern = r"send_eof\(\) requires at least TLSv1.3"
353-
if hasattr(ssl, "TLSVersion"):
354-
client_context.maximum_version = ssl.TLSVersion.TLSv1_2
355-
else: # Python 3.6
356-
client_context.options |= ssl.OP_NO_TLSv1_3
346+
client_context.maximum_version = ssl.TLSVersion.TLSv1_2
357347
else:
358348
expected_pattern = (
359349
r"send_eof\(\) has not yet been implemented for TLS streams"
@@ -397,7 +387,6 @@ async def test_default_context_ignore_unexpected_eof_flag_off(
397387

398388

399389
class TestTLSListener:
400-
@skip_on_broken_openssl
401390
async def test_handshake_fail(
402391
self, server_context: ssl.SSLContext, caplog: pytest.LogCaptureFixture
403392
) -> None:

tests/test_from_thread.py

-9
Original file line numberDiff line numberDiff line change
@@ -220,9 +220,6 @@ async def foo() -> None:
220220
exc.match("This function can only be run from an AnyIO worker thread")
221221

222222
async def test_contextvar_propagation(self, anyio_backend_name: str) -> None:
223-
if anyio_backend_name == "asyncio" and sys.version_info < (3, 7):
224-
pytest.skip("Asyncio does not propagate context before Python 3.7")
225-
226223
var = ContextVar("var", default=1)
227224

228225
async def async_func() -> int:
@@ -572,9 +569,6 @@ async def taskfunc(*, task_status: TaskStatus) -> None:
572569
def test_contextvar_propagation_sync(
573570
self, anyio_backend_name: str, anyio_backend_options: dict[str, Any]
574571
) -> None:
575-
if anyio_backend_name == "asyncio" and sys.version_info < (3, 7):
576-
pytest.skip("Asyncio does not propagate context before Python 3.7")
577-
578572
var = ContextVar("var", default=1)
579573
var.set(6)
580574
with start_blocking_portal(anyio_backend_name, anyio_backend_options) as portal:
@@ -585,9 +579,6 @@ def test_contextvar_propagation_sync(
585579
def test_contextvar_propagation_async(
586580
self, anyio_backend_name: str, anyio_backend_options: dict[str, Any]
587581
) -> None:
588-
if anyio_backend_name == "asyncio" and sys.version_info < (3, 7):
589-
pytest.skip("Asyncio does not propagate context before Python 3.7")
590-
591582
var = ContextVar("var", default=1)
592583
var.set(6)
593584

tests/test_subprocesses.py

-10
Original file line numberDiff line numberDiff line change
@@ -16,16 +16,6 @@
1616
pytestmark = pytest.mark.anyio
1717

1818

19-
@pytest.fixture(autouse=True)
20-
def check_compatibility(anyio_backend_name: str) -> None:
21-
if anyio_backend_name == "asyncio":
22-
if platform.system() == "Windows" and sys.version_info < (3, 8):
23-
pytest.skip(
24-
"Python < 3.8 uses SelectorEventLoop by default and it does not "
25-
"support subprocesses"
26-
)
27-
28-
2919
@pytest.mark.parametrize(
3020
"shell, command",
3121
[

tests/test_to_process.py

-11
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
from __future__ import annotations
22

33
import os
4-
import platform
54
import sys
65
import time
76
from functools import partial
@@ -21,16 +20,6 @@
2120
pytestmark = pytest.mark.anyio
2221

2322

24-
@pytest.fixture(autouse=True)
25-
def check_compatibility(anyio_backend_name: str) -> None:
26-
if anyio_backend_name == "asyncio":
27-
if platform.system() == "Windows" and sys.version_info < (3, 8):
28-
pytest.skip(
29-
"Python < 3.8 uses SelectorEventLoop by default and it does not "
30-
"support subprocesses"
31-
)
32-
33-
3423
async def test_run_sync_in_process_pool() -> None:
3524
"""
3625
Test that the function runs in a different process, and the same process in both

0 commit comments

Comments
 (0)