Switch from pytest-subtests to a mini-version that's faster (#8613)

This commit is contained in:
Alex Gaynor 2023-03-28 22:28:17 -04:00 committed by GitHub
parent 59a749333e
commit 22759dbab0
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 20 additions and 6 deletions

View file

@ -10,7 +10,6 @@ alabaster==0.7.13
attrs==22.2.0
# via
# pytest
# pytest-subtests
babel==2.12.1
# via sphinx
black==23.1.0
@ -125,7 +124,6 @@ pytest==7.2.2
# pytest-cov
# pytest-randomly
# pytest-shard
# pytest-subtests
# pytest-xdist
pytest-benchmark==4.0.0
# via cryptography (pyproject.toml)
@ -135,8 +133,6 @@ pytest-randomly==3.12.0
# via cryptography (pyproject.toml)
pytest-shard==0.1.2
# via cryptography (pyproject.toml)
pytest-subtests==0.10.0
# via cryptography (pyproject.toml)
pytest-xdist==3.2.1
# via cryptography (pyproject.toml)
readme-renderer==37.3

View file

@ -78,7 +78,6 @@ test = [
"pytest-shard >=0.1.2",
"pytest-benchmark",
"pytest-cov",
"pytest-subtests >=0.10.0",
"pytest-xdist",
"pretend",
]
@ -93,7 +92,7 @@ line-length = 79
target-version = ["py37"]
[tool.pytest.ini_options]
addopts = "-r s --capture=no --strict-markers --benchmark-disable --no-subtests-shortletter"
addopts = "-r s --capture=no --strict-markers --benchmark-disable"
console_output_style = "progress-even-when-capture-no"
markers = [
"skip_fips: this test is not executed in FIPS mode",

View file

@ -2,6 +2,7 @@
# 2.0, and the BSD License. See the LICENSE file in the root of this repository
# for complete details.
import contextlib
import pytest
@ -46,3 +47,21 @@ def backend(request):
# Ensure the error stack is clear after the test
errors = openssl_backend._consume_errors()
assert not errors
@pytest.fixture()
def subtests():
# This is a miniature version of the pytest-subtests package, but
# optimized for lower overhead.
#
# When tests are skipped, these are not logged in the final pytest output.
yield SubTests()
class SubTests:
@contextlib.contextmanager
def test(self):
try:
yield
except pytest.skip.Exception:
pass