From ca7d2dde01c35380e41fa560cf029d281e2cbd7d Mon Sep 17 00:00:00 2001 From: Henry Schreiner Date: Fri, 27 Sep 2024 02:12:42 -0400 Subject: [PATCH] tests: add some useful pytest config Signed-off-by: Henry Schreiner --- noxfile.py | 2 -- pyproject.toml | 9 +++++++++ tests/test_manylinux.py | 7 +++---- 3 files changed, 12 insertions(+), 6 deletions(-) diff --git a/noxfile.py b/noxfile.py index 454ba21c..aaee1e45 100644 --- a/noxfile.py +++ b/noxfile.py @@ -48,7 +48,6 @@ def coverage(*args): "packaging", "-m", "pytest", - "--strict-markers", *session.posargs, ) coverage("report", "-m", "--fail-under", "100") @@ -59,7 +58,6 @@ def coverage(*args): "-m", "pytest", "--capture=no", - "--strict-markers", *session.posargs, ) diff --git a/pyproject.toml b/pyproject.toml index 8c8a32db..e6fedc4b 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -40,6 +40,15 @@ include = ["LICENSE*", "tests/", "docs/", "CHANGELOG.rst"] exclude = ["docs/_build", "tests/manylinux/build-hello-world.sh", "tests/musllinux/build.sh", "tests/hello-world.c", "tests/__pycache__", "build/__pycache__"] +[tool.pytest.ini_options] +addopts = ["--strict-markers", "--strict-config"] +xfail_strict = true +filterwarnings = [ + "error", +] +testpaths = ["tests"] + + [tool.coverage.run] branch = true diff --git a/tests/test_manylinux.py b/tests/test_manylinux.py index 554059fc..e4634f9d 100644 --- a/tests/test_manylinux.py +++ b/tests/test_manylinux.py @@ -5,9 +5,9 @@ import os import pathlib import platform +import re import sys import types -import warnings import pretend import pytest @@ -72,10 +72,9 @@ def test_is_manylinux_compatible_glibc_support(version, compatible, monkeypatch) @pytest.mark.parametrize("version_str", ["glibc-2.4.5", "2"]) def test_check_glibc_version_warning(version_str): - with warnings.catch_warnings(record=True) as w: + msg = f"Expected glibc version with 2 components major.minor, got: {version_str}" + with pytest.warns(RuntimeWarning, match=re.escape(msg)): _parse_glibc_version(version_str) - assert len(w) == 1 - assert issubclass(w[0].category, RuntimeWarning) @pytest.mark.skipif(not ctypes, reason="requires ctypes")