Skip to content

Commit ada9c77

Browse files
authored
Avoid SSL tests on x86 Windows as cryptography doesn't support it (#3515)
1 parent 0480602 commit ada9c77

9 files changed

Lines changed: 36 additions & 24 deletions

File tree

‎.github/workflows/ci.yml‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -223,6 +223,7 @@ jobs:
223223
env:
224224
LSP: '${{ matrix.lsp }}'
225225
LSP_EXTRACT_FILE: '${{ matrix.lsp_extract_file }}'
226+
SKIP_SSL_INSTALLATION: "${{ matrix.arch == 'x86' && 1 || 0 }}"
226227
- if: always()
227228
uses: codecov/codecov-action@v7
228229
with:

‎ci.sh‎

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,8 +54,13 @@ if [ "${NO_TEST_REQUIREMENTS-0}" == 1 ]; then
5454
python -m uv pip install pytest coverage -c test-requirements.txt
5555
flags="--skip-optional-imports"
5656
else
57-
python -m uv pip install -r test-requirements.txt --no-deps
5857
flags=""
58+
if [ "${SKIP_SSL_INSTALLATION-0}" == 1 ]; then
59+
echo cryptography >excluded_deps
60+
PIP_ARGS="--exclude excluded_deps"
61+
flags="--skip-ssl-imports"
62+
fi
63+
python -m uv pip install -r test-requirements.txt --no-deps $PIP_ARGS
5964
fi
6065

6166
# If we're testing with a LSP installed, then it might break network

‎src/trio/_tests/pytest_plugin.py‎

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99

1010
RUN_SLOW = True
1111
SKIP_OPTIONAL_IMPORTS = False
12+
SKIP_SSL_IMPORTS = False
1213

1314

1415
def pytest_addoption(parser: pytest.Parser) -> None:
@@ -18,13 +19,18 @@ def pytest_addoption(parser: pytest.Parser) -> None:
1819
action="store_true",
1920
help="skip tests that rely on libraries not required by trio itself",
2021
)
22+
parser.addoption(
23+
"--skip-ssl-imports",
24+
action="store_true",
25+
help="skip tests that rely on cryptography",
26+
)
2127

2228

2329
def pytest_configure(config: pytest.Config) -> None:
24-
global RUN_SLOW
30+
global RUN_SLOW, SKIP_OPTIONAL_IMPORTS, SKIP_SSL_IMPORTS
2531
RUN_SLOW = config.getoption("--run-slow", default=True)
26-
global SKIP_OPTIONAL_IMPORTS
2732
SKIP_OPTIONAL_IMPORTS = config.getoption("--skip-optional-imports", default=False)
33+
SKIP_SSL_IMPORTS = config.getoption("--skip-ssl-imports", default=False)
2834

2935

3036
@pytest.fixture
@@ -47,8 +53,8 @@ def pytest_pyfunc_call(pyfuncitem: pytest.Function) -> None:
4753
pyfuncitem.obj = trio_test(pyfuncitem.obj)
4854

4955

50-
def skip_if_optional_else_raise(error: ImportError) -> NoReturn:
51-
if SKIP_OPTIONAL_IMPORTS:
56+
def maybe_ignore_import_error(error: ImportError) -> NoReturn:
57+
if SKIP_OPTIONAL_IMPORTS or (SKIP_SSL_IMPORTS and error.name == "cryptography"):
5258
pytest.skip(error.msg, allow_module_level=True)
5359
else: # pragma: no cover
5460
raise error

‎src/trio/_tests/test_dtls.py‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,13 +8,13 @@
88
import attrs
99
import pytest
1010

11-
from trio._tests.pytest_plugin import skip_if_optional_else_raise
11+
from trio._tests.pytest_plugin import maybe_ignore_import_error
1212

1313
try:
1414
import trustme
1515
from OpenSSL import SSL
1616
except ImportError as error:
17-
skip_if_optional_else_raise(error)
17+
maybe_ignore_import_error(error)
1818

1919

2020
import trio

‎src/trio/_tests/test_exports.py‎

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919

2020
import trio
2121
import trio.testing
22-
from trio._tests.pytest_plugin import RUN_SLOW, skip_if_optional_else_raise
22+
from trio._tests.pytest_plugin import RUN_SLOW, maybe_ignore_import_error
2323

2424
from .. import _core, _util
2525
from .._core._tests.tutil import slow
@@ -41,7 +41,7 @@ def _ensure_mypy_cache_updated() -> None:
4141
try:
4242
from mypy.api import run
4343
except ImportError as error:
44-
skip_if_optional_else_raise(error)
44+
maybe_ignore_import_error(error)
4545

4646
global mypy_cache_updated
4747
if not mypy_cache_updated:
@@ -159,7 +159,7 @@ def no_underscores(symbols: Iterable[str]) -> set[str]:
159159
try:
160160
from pylint.lint import PyLinter
161161
except ImportError as error:
162-
skip_if_optional_else_raise(error)
162+
maybe_ignore_import_error(error)
163163

164164
linter = PyLinter()
165165
assert module.__file__ is not None
@@ -172,7 +172,7 @@ def no_underscores(symbols: Iterable[str]) -> set[str]:
172172
try:
173173
import jedi
174174
except ImportError as error:
175-
skip_if_optional_else_raise(error)
175+
maybe_ignore_import_error(error)
176176

177177
# Simulate typing "import trio; trio.<TAB>"
178178
script = jedi.Script(f"import {modname}; {modname}.")
@@ -215,7 +215,7 @@ def no_underscores(symbols: Iterable[str]) -> set[str]:
215215
try:
216216
import pyright # noqa: F401
217217
except ImportError as error:
218-
skip_if_optional_else_raise(error)
218+
maybe_ignore_import_error(error)
219219
import subprocess
220220

221221
res = subprocess.run(
@@ -380,7 +380,7 @@ def lookup_symbol(symbol: str) -> dict[str, Any]: # type: ignore[misc, explicit
380380
try:
381381
import jedi
382382
except ImportError as error:
383-
skip_if_optional_else_raise(error)
383+
maybe_ignore_import_error(error)
384384

385385
script = jedi.Script(
386386
f"from {module_name} import {class_name}; {class_name}.",

‎src/trio/_tests/test_ssl.py‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,15 +13,15 @@
1313
import pytest
1414

1515
from trio import StapledStream
16-
from trio._tests.pytest_plugin import skip_if_optional_else_raise
16+
from trio._tests.pytest_plugin import maybe_ignore_import_error
1717
from trio.abc import ReceiveStream, SendStream
1818
from trio.testing import MemoryReceiveStream, MemorySendStream
1919

2020
try:
2121
import trustme
2222
from OpenSSL import SSL
2323
except ImportError as error:
24-
skip_if_optional_else_raise(error)
24+
maybe_ignore_import_error(error)
2525

2626
import trio
2727

‎src/trio/_tests/tools/test_gen_exports.py‎

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,14 +4,14 @@
44

55
import pytest
66

7-
from trio._tests.pytest_plugin import skip_if_optional_else_raise
7+
from trio._tests.pytest_plugin import maybe_ignore_import_error
88

99
# imports in gen_exports that are not in `install_requires` in setup.py
1010
try:
1111
import astor # noqa: F401
1212
import isort # noqa: F401
1313
except ImportError as error:
14-
skip_if_optional_else_raise(error)
14+
maybe_ignore_import_error(error)
1515

1616

1717
from trio._tools.gen_exports import (
@@ -103,7 +103,7 @@ def test_process(
103103
import black # noqa: F401
104104
# there's no dedicated CI run that has astor+isort, but lacks black.
105105
except ImportError as error: # pragma: no cover
106-
skip_if_optional_else_raise(error)
106+
maybe_ignore_import_error(error)
107107

108108
modpath = tmp_path / "_module.py"
109109
genpath = tmp_path / "_generated_module.py"
@@ -141,7 +141,7 @@ def test_run_ruff(tmp_path: Path) -> None:
141141
try:
142142
import ruff # noqa: F401
143143
except ImportError as error: # pragma: no cover
144-
skip_if_optional_else_raise(error)
144+
maybe_ignore_import_error(error)
145145

146146
file = File(tmp_path / "module.py", "module")
147147

@@ -168,7 +168,7 @@ def test_lint_failure(tmp_path: Path) -> None:
168168
import black # noqa: F401
169169
import ruff # noqa: F401
170170
except ImportError as error: # pragma: no cover
171-
skip_if_optional_else_raise(error)
171+
maybe_ignore_import_error(error)
172172

173173
file = File(tmp_path / "module.py", "module")
174174

‎src/trio/_tests/tools/test_sync_requirements.py‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,13 @@
22

33
from typing import TYPE_CHECKING
44

5-
from trio._tests.pytest_plugin import skip_if_optional_else_raise
5+
from trio._tests.pytest_plugin import maybe_ignore_import_error
66

77
# imports in gen_exports that are not in `install_requires` in requirements
88
try:
99
import yaml # noqa: F401
1010
except ImportError as error:
11-
skip_if_optional_else_raise(error)
11+
maybe_ignore_import_error(error)
1212

1313
from trio._tools.sync_requirements import (
1414
update_requirements,

‎test-requirements.txt‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ colorama==0.4.6 ; sys_platform == 'win32'
3939
# sphinx
4040
coverage==7.16.0
4141
# via -r test-requirements.in
42-
cryptography==48.0.0
42+
cryptography==50.0.1
4343
# via
4444
# -r test-requirements.in
4545
# pyopenssl
@@ -126,7 +126,7 @@ pygments==2.21.0
126126
# sphinx
127127
pylint==4.0.8
128128
# via -r test-requirements.in
129-
pyopenssl==26.2.0
129+
pyopenssl==26.4.0
130130
# via -r test-requirements.in
131131
pyright==1.1.411
132132
# via -r test-requirements.in

0 commit comments

Comments
 (0)