mirror of
https://github.com/openwrt/packages.git
synced 2026-04-15 19:02:09 +00:00
python-pytest: bump to 9.0.2
Changelog since 7.4.0: - v8.1.0: Add namespace packages support; fine-grained verbosity control; improved --import-mode=importlib behavior - v8.2.0: Add command-line argument files via @filename syntax; add PYTEST_VERSION env variable; requires pluggy>=1.5.0 - v8.3.0: Add --xfail-tb flag; marker keyword matching; --no-fold-skipped option; better virtual environment detection - v8.4.0: Async tests without suitable plugin now fail (not warned); tests returning non-None values now fail; drop Python 3.8 support; add pytest.RaisesGroup for ExceptionGroup matching - v9.0.0: Drop Python 3.9 support; subtest support via pytest.Subtests; native TOML config in [tool.pytest] table; strict mode options; PytestRemovedIn9Warning deprecations are now errors - v9.0.1: Restore "raise unittest.SkipTest" support; disable terminal progress for iTerm2 - v9.0.2: Disable terminal progress by default; fix config.inicfg compatibility; fix quadratic-time behavior with unittest subtests Add python3-pygments dependency (new requirement since 8.x). Add test.sh. Full changelog: https://github.com/pytest-dev/pytest/releases Signed-off-by: Alexandru Ardelean <alex@shruggie.ro>
This commit is contained in:
committed by
Alexandru Ardelean
parent
78d8eedb78
commit
4edd68feda
@@ -8,11 +8,11 @@
|
||||
include $(TOPDIR)/rules.mk
|
||||
|
||||
PKG_NAME:=python-pytest
|
||||
PKG_VERSION:=7.4.0
|
||||
PKG_VERSION:=9.0.2
|
||||
PKG_RELEASE:=1
|
||||
|
||||
PYPI_NAME:=pytest
|
||||
PKG_HASH:=b4bf8c45bd59934ed84001ad51e11b4ee40d40a1229d2c79f9c592b0a3f6bd8a
|
||||
PKG_HASH:=75186651a92bd89611d1d9fc20f0b4345fd827c41ccd5c299a868a05d70edf11
|
||||
|
||||
PKG_MAINTAINER:=Jan Pavlinec <jan.pavlinec1@gmail.com>, Alexandru Ardelean <ardeleanalex@gmail.com>
|
||||
PKG_LICENSE:=MIT
|
||||
@@ -34,7 +34,8 @@ define Package/python3-pytest
|
||||
+python3 \
|
||||
+python3-iniconfig \
|
||||
+python3-packaging \
|
||||
+python3-pluggy
|
||||
+python3-pluggy \
|
||||
+python3-pygments
|
||||
endef
|
||||
|
||||
define Package/python3-pytest/description
|
||||
|
||||
110
lang/python/python-pytest/test.sh
Executable file
110
lang/python/python-pytest/test.sh
Executable file
@@ -0,0 +1,110 @@
|
||||
#!/bin/sh
|
||||
|
||||
[ "$1" = python3-pytest ] || exit 0
|
||||
|
||||
# Verify version
|
||||
python3 - << EOF
|
||||
import importlib.metadata, sys
|
||||
version = importlib.metadata.version("pytest")
|
||||
if version != "$2":
|
||||
print("Wrong version: " + version)
|
||||
sys.exit(1)
|
||||
EOF
|
||||
[ $? -eq 0 ] || exit 1
|
||||
|
||||
# Run pytest against a temporary suite that exercises core features
|
||||
TMPDIR=$(mktemp -d)
|
||||
trap 'rm -rf "$TMPDIR"' EXIT
|
||||
|
||||
cat > "$TMPDIR/test_suite.py" << 'PYEOF'
|
||||
import pytest
|
||||
|
||||
# --- basic pass/fail ---
|
||||
|
||||
def test_passing():
|
||||
assert 1 + 1 == 2
|
||||
|
||||
# --- pytest.raises ---
|
||||
|
||||
def test_raises():
|
||||
with pytest.raises(ZeroDivisionError):
|
||||
1 / 0
|
||||
|
||||
def test_raises_match():
|
||||
with pytest.raises(ValueError, match="invalid"):
|
||||
raise ValueError("invalid literal")
|
||||
|
||||
# --- parametrize ---
|
||||
|
||||
@pytest.mark.parametrize("a,b,expected", [
|
||||
(1, 2, 3),
|
||||
(0, 0, 0),
|
||||
(-1, 1, 0),
|
||||
])
|
||||
def test_add(a, b, expected):
|
||||
assert a + b == expected
|
||||
|
||||
# --- fixtures ---
|
||||
|
||||
@pytest.fixture
|
||||
def sample_list():
|
||||
return [1, 2, 3]
|
||||
|
||||
def test_fixture_used(sample_list):
|
||||
assert len(sample_list) == 3
|
||||
assert sum(sample_list) == 6
|
||||
|
||||
@pytest.fixture
|
||||
def doubled(sample_list):
|
||||
return [x * 2 for x in sample_list]
|
||||
|
||||
def test_fixture_chaining(doubled):
|
||||
assert doubled == [2, 4, 6]
|
||||
|
||||
# --- skip / xfail ---
|
||||
|
||||
@pytest.mark.skip(reason="intentional skip")
|
||||
def test_skipped():
|
||||
assert False # never runs
|
||||
|
||||
@pytest.mark.xfail(reason="expected failure")
|
||||
def test_xfail():
|
||||
assert False
|
||||
|
||||
@pytest.mark.xfail(reason="unexpectedly passes")
|
||||
def test_xpass():
|
||||
assert True
|
||||
|
||||
# --- capsys fixture ---
|
||||
|
||||
def test_capsys(capsys):
|
||||
print("hello pytest")
|
||||
out, err = capsys.readouterr()
|
||||
assert out == "hello pytest\n"
|
||||
assert err == ""
|
||||
|
||||
# --- tmp_path fixture ---
|
||||
|
||||
def test_tmp_path(tmp_path):
|
||||
f = tmp_path / "hello.txt"
|
||||
f.write_text("world")
|
||||
assert f.read_text() == "world"
|
||||
|
||||
# --- monkeypatch fixture ---
|
||||
|
||||
def get_value():
|
||||
return 42
|
||||
|
||||
def test_monkeypatch(monkeypatch):
|
||||
import test_suite
|
||||
monkeypatch.setattr(test_suite, "get_value", lambda: 99)
|
||||
assert get_value() == 99
|
||||
|
||||
PYEOF
|
||||
|
||||
# Run pytest: expect all to pass (xpass counts as pass by default)
|
||||
python3 -m pytest "$TMPDIR/test_suite.py" -v --tb=short 2>&1
|
||||
STATUS=$?
|
||||
|
||||
# xpass (test_xpass) causes exit code 0 by default — that's fine
|
||||
[ $STATUS -eq 0 ] || exit 1
|
||||
Reference in New Issue
Block a user