Skip to content

Commit

Permalink
Remove conditionals and workarounds for Python interpreter versions 3…
Browse files Browse the repository at this point in the history
….7 and older (#688)
  • Loading branch information
musicinmybrain authored Feb 8, 2024
1 parent 7565f31 commit 5426f7b
Show file tree
Hide file tree
Showing 4 changed files with 1 addition and 42 deletions.
13 changes: 1 addition & 12 deletions tests/streams/test_tls.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@

import socket
import ssl
import sys
from contextlib import ExitStack
from threading import Thread
from typing import ContextManager, NoReturn
Expand All @@ -26,10 +25,6 @@
from anyio.streams.tls import TLSAttribute, TLSListener, TLSStream

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


class TestTLSStream:
Expand Down Expand Up @@ -193,7 +188,6 @@ def serve_sync() -> None:
pytest.param(False, False, id="neither_standard"),
],
)
@skip_on_broken_openssl
async def test_ragged_eofs(
self,
server_context: ssl.SSLContext,
Expand Down Expand Up @@ -250,7 +244,6 @@ def serve_sync() -> None:
else:
assert server_exc is None

@skip_on_broken_openssl
async def test_ragged_eof_on_receive(
self, server_context: ssl.SSLContext, client_context: ssl.SSLContext
) -> None:
Expand Down Expand Up @@ -350,10 +343,7 @@ def serve_sync() -> None:
ca.configure_trust(client_context)
if force_tlsv12:
expected_pattern = r"send_eof\(\) requires at least TLSv1.3"
if hasattr(ssl, "TLSVersion"):
client_context.maximum_version = ssl.TLSVersion.TLSv1_2
else: # Python 3.6
client_context.options |= ssl.OP_NO_TLSv1_3
client_context.maximum_version = ssl.TLSVersion.TLSv1_2
else:
expected_pattern = (
r"send_eof\(\) has not yet been implemented for TLS streams"
Expand Down Expand Up @@ -397,7 +387,6 @@ async def test_default_context_ignore_unexpected_eof_flag_off(


class TestTLSListener:
@skip_on_broken_openssl
async def test_handshake_fail(
self, server_context: ssl.SSLContext, caplog: pytest.LogCaptureFixture
) -> None:
Expand Down
9 changes: 0 additions & 9 deletions tests/test_from_thread.py
Original file line number Diff line number Diff line change
Expand Up @@ -220,9 +220,6 @@ async def foo() -> None:
exc.match("This function can only be run from an AnyIO worker thread")

async def test_contextvar_propagation(self, anyio_backend_name: str) -> None:
if anyio_backend_name == "asyncio" and sys.version_info < (3, 7):
pytest.skip("Asyncio does not propagate context before Python 3.7")

var = ContextVar("var", default=1)

async def async_func() -> int:
Expand Down Expand Up @@ -572,9 +569,6 @@ async def taskfunc(*, task_status: TaskStatus) -> None:
def test_contextvar_propagation_sync(
self, anyio_backend_name: str, anyio_backend_options: dict[str, Any]
) -> None:
if anyio_backend_name == "asyncio" and sys.version_info < (3, 7):
pytest.skip("Asyncio does not propagate context before Python 3.7")

var = ContextVar("var", default=1)
var.set(6)
with start_blocking_portal(anyio_backend_name, anyio_backend_options) as portal:
Expand All @@ -585,9 +579,6 @@ def test_contextvar_propagation_sync(
def test_contextvar_propagation_async(
self, anyio_backend_name: str, anyio_backend_options: dict[str, Any]
) -> None:
if anyio_backend_name == "asyncio" and sys.version_info < (3, 7):
pytest.skip("Asyncio does not propagate context before Python 3.7")

var = ContextVar("var", default=1)
var.set(6)

Expand Down
10 changes: 0 additions & 10 deletions tests/test_subprocesses.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,16 +16,6 @@
pytestmark = pytest.mark.anyio


@pytest.fixture(autouse=True)
def check_compatibility(anyio_backend_name: str) -> None:
if anyio_backend_name == "asyncio":
if platform.system() == "Windows" and sys.version_info < (3, 8):
pytest.skip(
"Python < 3.8 uses SelectorEventLoop by default and it does not "
"support subprocesses"
)


@pytest.mark.parametrize(
"shell, command",
[
Expand Down
11 changes: 0 additions & 11 deletions tests/test_to_process.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
from __future__ import annotations

import os
import platform
import sys
import time
from functools import partial
Expand All @@ -21,16 +20,6 @@
pytestmark = pytest.mark.anyio


@pytest.fixture(autouse=True)
def check_compatibility(anyio_backend_name: str) -> None:
if anyio_backend_name == "asyncio":
if platform.system() == "Windows" and sys.version_info < (3, 8):
pytest.skip(
"Python < 3.8 uses SelectorEventLoop by default and it does not "
"support subprocesses"
)


async def test_run_sync_in_process_pool() -> None:
"""
Test that the function runs in a different process, and the same process in both
Expand Down

0 comments on commit 5426f7b

Please sign in to comment.