dev-python/pytest: treeclean

Signed-off-by: Andreas Billmeier <b@edevau.net>
This commit is contained in:
2024-04-12 21:35:42 +02:00
parent fa95ae0286
commit f48b140f8d
8 changed files with 2 additions and 481 deletions

View File

@@ -1,7 +0,0 @@
AUX pytest-3.4.2-pypy-syntaxerror-offset.patch 996 BLAKE2B ff6d362d20f6432f73956e1aee4c2bc596e3d8e3347da3624dfd3cbfdd1eabd8872058737e8f9b558f3570878756c7b87a65514956b1e81235c2727e8ff2fc63 SHA512 4a28ddc07389aac79e46528e85229aba126a89c27b7bec73b406766be49f5c8be9bdc2cb3158bfb475b4d6371e2f33960e1ed154e3b9eda15aeb8b151f3d2148
AUX pytest-4.5.0-strip-setuptools_scm.patch 674 BLAKE2B 4eab3e26423d81614223a88a0124dc4f35892b18ecbcce34280a00774012822fced0045ac7113a50f8f88d042b88e404dbf4d8d3760140c66a48daa3da2a44c6 SHA512 d34d7c1db57804f0d1ff71f3f51c9a736592945fdf564f54c0c20c398c86f08616eb21f75d77457a71738df4d254ec3d69e46aa3378dea6f7913933bcdf45c08
AUX pytest-7.3.1-py312.patch 11621 BLAKE2B 20e7132c8bbd16a8b01af8bf80254148434f7846463dffc4d46b731334d5b7959de9c3c3280d06a340c55bea608a3c516a31969ea0db7ce806581022537377b0 SHA512 17c0e3e2e119b9ce895d97fef9e1729c5f1577b2d5a3f6a650b7e94fccf8783a4686e4ddc7fa80209661dc4397f3c862dc809c531c136cafce477682b37223b6
AUX pytest-7.4.3-no-color.patch 1293 BLAKE2B 85ae23dc612eb7825f4c3ba2d727a6115540118269ae2748fcb4b39b958180078f0c171562a84879f7b18da16149fb40d06be36e782abf41133ae6d510414490 SHA512 7550397bb42f08c886dd72674a4bfd53dbe449e30c1fe51358b77eb055d3626c053167a27cc2b0883151a4651b6133be222dcf78cab8675b980c79836f72ae57
DIST pytest-7.4.3.tar.gz 1356179 BLAKE2B 2f4fd893aaf9867f20548eababc7aac6f4978253bcc4a35c50f7e2327a48458bc184f2340764ee7fed3dd02bc779ed03f084a0d8839a18f614d32245888c4f56 SHA512 1b80e9b7e0ba8fe966d6658aa72d49d101190f255acd9eb81d66142327535b7108c921055d8fe3e330e3ff4163aa03d7c67b2807d433dd9e1799be6a59b208c9
EBUILD pytest-7.4.3.ebuild 3575 BLAKE2B 809a5e126b564a1261ee286c64e5048fc9efb0c05c51be15205ebdc8da06059168672dfd120df57ae75181425c572381bf5d038300381f937260f891ea149e84 SHA512 fd37392ab5f99b15e1cad340f4bd03f0bffa3b122d4f8387505168c3e16cf560e945b646f42ebc213fefa8886490bb6fb16ff372f4b3518c2c2c71762bb66c01
MISC metadata.xml 391 BLAKE2B 48d31ecb4c8b171ee4e84a58399211368ddc00dfb5dbe0999f96e03d744294cd4fd5263e90600c93d1f13c7da21052faef84b6d0d56709f3559e37b3392ca31d SHA512 6e9caa57eda23995d21df6f52c52d5868e1ff56abb6c1351ffc0fe14b771639473481a2630e659caaff83f0255379aa2d012175af52a0de41221b27d3ab2f425

View File

@@ -1,27 +0,0 @@
https://salsa.debian.org/python-team/modules/pytest/commit/405c05a0827592515de76e23c94de1f7773273e6.patch
From 405c05a0827592515de76e23c94de1f7773273e6 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Ond=C5=99ej=20Nov=C3=BD?= <onovy@debian.org>
Date: Thu, 10 May 2018 11:42:56 +0200
Subject: [PATCH] Fix PyPy SyntaxError offset in tests
---
testing/code/test_source.py | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/testing/code/test_source.py b/testing/code/test_source.py
index fcce3fa..22278d8 100644
--- a/testing/code/test_source.py
+++ b/testing/code/test_source.py
@@ -117,7 +117,7 @@ def test_source_strip_multiline():
def test_syntaxerror_rerepresentation():
ex = pytest.raises(SyntaxError, _pytest._code.compile, 'xyz xyz')
assert ex.value.lineno == 1
- assert ex.value.offset in (4, 7) # XXX pypy/jython versus cpython?
+ assert ex.value.offset in (4, 5, 7) # XXX pypy/jython versus cpython?
assert ex.value.text.strip(), 'x x'
--
2.18.0

View File

@@ -1,25 +0,0 @@
diff --git a/setup.py b/setup.py
index 0fb5a58a..302b5dda 100644
--- a/setup.py
+++ b/setup.py
@@ -1,4 +1,5 @@
from setuptools import setup
+import os
# TODO: if py gets upgrade to >=1.6,
# remove _width_of_current_line in terminal.py
@@ -18,10 +19,12 @@ INSTALL_REQUIRES = [
]
+with open("src/_pytest/_version.py", 'wt') as fp:
+ fp.write('version = "{}"'.format(os.environ['PV']))
+
def main():
setup(
- use_scm_version={"write_to": "src/_pytest/_version.py"},
- setup_requires=["setuptools-scm", "setuptools>=40.0"],
+ version=os.environ['PV'],
package_dir={"": "src"},
# fmt: off
extras_require={

View File

@@ -1,258 +0,0 @@
From 653606791456f7e6412712bc26428b90092336b5 Mon Sep 17 00:00:00 2001
From: Ran Benita <ran@unusedvar.com>
Date: Wed, 10 May 2023 10:36:09 +0300
Subject: [PATCH] Avoid ast deprecation warnings on Python 3.12
Fix #10977.
---
src/_pytest/assertion/rewrite.py | 49 +++++++++++++++++++-------------
src/_pytest/mark/expression.py | 8 +++++-
2 files changed, 36 insertions(+), 21 deletions(-)
diff --git a/src/_pytest/assertion/rewrite.py b/src/_pytest/assertion/rewrite.py
index 8b182347052..00bb4feb94a 100644
--- a/src/_pytest/assertion/rewrite.py
+++ b/src/_pytest/assertion/rewrite.py
@@ -46,8 +46,14 @@
if sys.version_info >= (3, 8):
namedExpr = ast.NamedExpr
+ astNameConstant = ast.Constant
+ astStr = ast.Constant
+ astNum = ast.Constant
else:
namedExpr = ast.Expr
+ astNameConstant = ast.NameConstant
+ astStr = ast.Str
+ astNum = ast.Num
assertstate_key = StashKey["AssertionState"]()
@@ -680,9 +686,12 @@ def run(self, mod: ast.Module) -> None:
if (
expect_docstring
and isinstance(item, ast.Expr)
- and isinstance(item.value, ast.Str)
+ and isinstance(item.value, astStr)
):
- doc = item.value.s
+ if sys.version_info >= (3, 8):
+ doc = item.value.value
+ else:
+ doc = item.value.s
if self.is_rewrite_disabled(doc):
return
expect_docstring = False
@@ -814,7 +823,7 @@ def pop_format_context(self, expl_expr: ast.expr) -> ast.Name:
current = self.stack.pop()
if self.stack:
self.explanation_specifiers = self.stack[-1]
- keys = [ast.Str(key) for key in current.keys()]
+ keys = [astStr(key) for key in current.keys()]
format_dict = ast.Dict(keys, list(current.values()))
form = ast.BinOp(expl_expr, ast.Mod(), format_dict)
name = "@py_format" + str(next(self.variable_counter))
@@ -868,16 +877,16 @@ def visit_Assert(self, assert_: ast.Assert) -> List[ast.stmt]:
negation = ast.UnaryOp(ast.Not(), top_condition)
if self.enable_assertion_pass_hook: # Experimental pytest_assertion_pass hook
- msg = self.pop_format_context(ast.Str(explanation))
+ msg = self.pop_format_context(astStr(explanation))
# Failed
if assert_.msg:
assertmsg = self.helper("_format_assertmsg", assert_.msg)
gluestr = "\n>assert "
else:
- assertmsg = ast.Str("")
+ assertmsg = astStr("")
gluestr = "assert "
- err_explanation = ast.BinOp(ast.Str(gluestr), ast.Add(), msg)
+ err_explanation = ast.BinOp(astStr(gluestr), ast.Add(), msg)
err_msg = ast.BinOp(assertmsg, ast.Add(), err_explanation)
err_name = ast.Name("AssertionError", ast.Load())
fmt = self.helper("_format_explanation", err_msg)
@@ -893,8 +902,8 @@ def visit_Assert(self, assert_: ast.Assert) -> List[ast.stmt]:
hook_call_pass = ast.Expr(
self.helper(
"_call_assertion_pass",
- ast.Num(assert_.lineno),
- ast.Str(orig),
+ astNum(assert_.lineno),
+ astStr(orig),
fmt_pass,
)
)
@@ -913,7 +922,7 @@ def visit_Assert(self, assert_: ast.Assert) -> List[ast.stmt]:
variables = [
ast.Name(name, ast.Store()) for name in self.format_variables
]
- clear_format = ast.Assign(variables, ast.NameConstant(None))
+ clear_format = ast.Assign(variables, astNameConstant(None))
self.statements.append(clear_format)
else: # Original assertion rewriting
@@ -924,9 +933,9 @@ def visit_Assert(self, assert_: ast.Assert) -> List[ast.stmt]:
assertmsg = self.helper("_format_assertmsg", assert_.msg)
explanation = "\n>assert " + explanation
else:
- assertmsg = ast.Str("")
+ assertmsg = astStr("")
explanation = "assert " + explanation
- template = ast.BinOp(assertmsg, ast.Add(), ast.Str(explanation))
+ template = ast.BinOp(assertmsg, ast.Add(), astStr(explanation))
msg = self.pop_format_context(template)
fmt = self.helper("_format_explanation", msg)
err_name = ast.Name("AssertionError", ast.Load())
@@ -938,7 +947,7 @@ def visit_Assert(self, assert_: ast.Assert) -> List[ast.stmt]:
# Clear temporary variables by setting them to None.
if self.variables:
variables = [ast.Name(name, ast.Store()) for name in self.variables]
- clear = ast.Assign(variables, ast.NameConstant(None))
+ clear = ast.Assign(variables, astNameConstant(None))
self.statements.append(clear)
# Fix locations (line numbers/column offsets).
for stmt in self.statements:
@@ -952,20 +961,20 @@ def visit_NamedExpr(self, name: namedExpr) -> Tuple[namedExpr, str]:
# thinks it's acceptable.
locs = ast.Call(self.builtin("locals"), [], [])
target_id = name.target.id # type: ignore[attr-defined]
- inlocs = ast.Compare(ast.Str(target_id), [ast.In()], [locs])
+ inlocs = ast.Compare(astStr(target_id), [ast.In()], [locs])
dorepr = self.helper("_should_repr_global_name", name)
test = ast.BoolOp(ast.Or(), [inlocs, dorepr])
- expr = ast.IfExp(test, self.display(name), ast.Str(target_id))
+ expr = ast.IfExp(test, self.display(name), astStr(target_id))
return name, self.explanation_param(expr)
def visit_Name(self, name: ast.Name) -> Tuple[ast.Name, str]:
# Display the repr of the name if it's a local variable or
# _should_repr_global_name() thinks it's acceptable.
locs = ast.Call(self.builtin("locals"), [], [])
- inlocs = ast.Compare(ast.Str(name.id), [ast.In()], [locs])
+ inlocs = ast.Compare(astStr(name.id), [ast.In()], [locs])
dorepr = self.helper("_should_repr_global_name", name)
test = ast.BoolOp(ast.Or(), [inlocs, dorepr])
- expr = ast.IfExp(test, self.display(name), ast.Str(name.id))
+ expr = ast.IfExp(test, self.display(name), astStr(name.id))
return name, self.explanation_param(expr)
def visit_BoolOp(self, boolop: ast.BoolOp) -> Tuple[ast.Name, str]:
@@ -1001,7 +1010,7 @@ def visit_BoolOp(self, boolop: ast.BoolOp) -> Tuple[ast.Name, str]:
self.push_format_context()
res, expl = self.visit(v)
body.append(ast.Assign([ast.Name(res_var, ast.Store())], res))
- expl_format = self.pop_format_context(ast.Str(expl))
+ expl_format = self.pop_format_context(astStr(expl))
call = ast.Call(app, [expl_format], [])
self.expl_stmts.append(ast.Expr(call))
if i < levels:
@@ -1013,7 +1022,7 @@ def visit_BoolOp(self, boolop: ast.BoolOp) -> Tuple[ast.Name, str]:
self.statements = body = inner
self.statements = save
self.expl_stmts = fail_save
- expl_template = self.helper("_format_boolop", expl_list, ast.Num(is_or))
+ expl_template = self.helper("_format_boolop", expl_list, astNum(is_or))
expl = self.pop_format_context(expl_template)
return ast.Name(res_var, ast.Load()), self.explanation_param(expl)
@@ -1099,9 +1108,9 @@ def visit_Compare(self, comp: ast.Compare) -> Tuple[ast.expr, str]:
next_expl = f"({next_expl})"
results.append(next_res)
sym = BINOP_MAP[op.__class__]
- syms.append(ast.Str(sym))
+ syms.append(astStr(sym))
expl = f"{left_expl} {sym} {next_expl}"
- expls.append(ast.Str(expl))
+ expls.append(astStr(expl))
res_expr = ast.Compare(left_res, [op], [next_res])
self.statements.append(ast.Assign([store_names[i]], res_expr))
left_res, left_expl = next_res, next_expl
diff --git a/src/_pytest/mark/expression.py b/src/_pytest/mark/expression.py
index f82a81d44c5..9287bcee50c 100644
--- a/src/_pytest/mark/expression.py
+++ b/src/_pytest/mark/expression.py
@@ -18,6 +18,7 @@
import dataclasses
import enum
import re
+import sys
import types
from typing import Callable
from typing import Iterator
@@ -26,6 +27,11 @@
from typing import Optional
from typing import Sequence
+if sys.version_info >= (3, 8):
+ astNameConstant = ast.Constant
+else:
+ astNameConstant = ast.NameConstant
+
__all__ = [
"Expression",
@@ -132,7 +138,7 @@ def reject(self, expected: Sequence[TokenType]) -> NoReturn:
def expression(s: Scanner) -> ast.Expression:
if s.accept(TokenType.EOF):
- ret: ast.expr = ast.NameConstant(False)
+ ret: ast.expr = astNameConstant(False)
else:
ret = expr(s)
s.accept(TokenType.EOF, reject=True)
From c945dba571025623a3ace7311d682e3e9448a161 Mon Sep 17 00:00:00 2001
From: Ran Benita <ran@unusedvar.com>
Date: Fri, 26 May 2023 20:28:21 +0300
Subject: [PATCH] testing/python/collect: replace use of deprecated/removed
`imp` module
---
testing/python/collect.py | 26 +++++++++++++++-----------
1 file changed, 15 insertions(+), 11 deletions(-)
diff --git a/testing/python/collect.py b/testing/python/collect.py
index ac3edd395ab..52b34800965 100644
--- a/testing/python/collect.py
+++ b/testing/python/collect.py
@@ -897,25 +897,29 @@ def pytest_pycollect_makeitem(collector, name, obj):
def test_issue2369_collect_module_fileext(self, pytester: Pytester) -> None:
"""Ensure we can collect files with weird file extensions as Python
modules (#2369)"""
- # We'll implement a little finder and loader to import files containing
+ # Implement a little meta path finder to import files containing
# Python source code whose file extension is ".narf".
pytester.makeconftest(
"""
- import sys, os, imp
+ import sys
+ import os.path
+ from importlib.util import spec_from_loader
+ from importlib.machinery import SourceFileLoader
from _pytest.python import Module
- class Loader(object):
- def load_module(self, name):
- return imp.load_source(name, name + ".narf")
- class Finder(object):
- def find_module(self, name, path=None):
- if os.path.exists(name + ".narf"):
- return Loader()
- sys.meta_path.append(Finder())
+ class MetaPathFinder:
+ def find_spec(self, fullname, path, target=None):
+ if os.path.exists(fullname + ".narf"):
+ return spec_from_loader(
+ fullname,
+ SourceFileLoader(fullname, fullname + ".narf"),
+ )
+ sys.meta_path.append(MetaPathFinder())
def pytest_collect_file(file_path, parent):
if file_path.suffix == ".narf":
- return Module.from_parent(path=file_path, parent=parent)"""
+ return Module.from_parent(path=file_path, parent=parent)
+ """
)
pytester.makefile(
".narf",

View File

@@ -1,37 +0,0 @@
From ce93a8ad7a11d1e9be76ce6af0d510f935622c1f Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Micha=C5=82=20G=C3=B3rny?= <mgorny@gentoo.org>
Date: Sat, 25 Nov 2023 12:09:32 +0100
Subject: [PATCH] Reset color-related envvars for testing
Reset color-related environment variables in a fixture to prevent them
from affecting test results. Otherwise, some of the tests fail
e.g. if NO_COLOR is set in the calling environment.
---
testing/conftest.py | 11 +++++++++++
1 file changed, 11 insertions(+)
diff --git a/testing/conftest.py b/testing/conftest.py
index 2a3ce5203..612777304 100644
--- a/testing/conftest.py
+++ b/testing/conftest.py
@@ -30,6 +30,17 @@ def set_column_width(monkeypatch: pytest.MonkeyPatch) -> None:
monkeypatch.setenv("COLUMNS", "80")
+@pytest.fixture(autouse=True)
+def reset_colors(monkeypatch: pytest.MonkeyPatch) -> None:
+ """
+ Reset all color-related variables to prevent them from affecting internal pytest output
+ in tests that depend on it.
+ """
+ monkeypatch.delenv("PY_COLORS", raising=False)
+ monkeypatch.delenv("NO_COLOR", raising=False)
+ monkeypatch.delenv("FORCE_COLOR", raising=False)
+
+
@pytest.hookimpl(hookwrapper=True, tryfirst=True)
def pytest_collection_modifyitems(items):
"""Prefer faster tests.
--
2.43.0

View File

@@ -1,13 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE pkgmetadata SYSTEM "https://www.gentoo.org/dtd/metadata.dtd">
<pkgmetadata>
<maintainer type="project">
<email>python@gentoo.org</email>
<name>Python</name>
</maintainer>
<stabilize-allarches/>
<upstream>
<remote-id type="pypi">pytest</remote-id>
<remote-id type="github">pytest-dev/pytest</remote-id>
</upstream>
</pkgmetadata>

View File

@@ -1,112 +0,0 @@
# Copyright 1999-2024 Gentoo Authors
# Distributed under the terms of the GNU General Public License v2
EAPI=8
DISTUTILS_USE_PEP517=setuptools
PYTHON_TESTED=( python3_{10..12} pypy3 )
PYTHON_COMPAT=( python3_{11..12} )
inherit distutils-r1 multiprocessing pypi
DESCRIPTION="Simple powerful testing with Python"
HOMEPAGE="
https://pytest.org/
https://github.com/pytest-dev/pytest/
https://pypi.org/project/pytest/
"
LICENSE="MIT"
SLOT="0"
KEYWORDS="amd64 arm arm64 x86"
IUSE="test"
RESTRICT="!test? ( test )"
RDEPEND="
dev-python/iniconfig[${PYTHON_USEDEP}]
>=dev-python/more-itertools-4.0.0[${PYTHON_USEDEP}]
dev-python/packaging[${PYTHON_USEDEP}]
>=dev-python/pluggy-0.12[${PYTHON_USEDEP}]
$(python_gen_cond_dep '
>=dev-python/exceptiongroup-1.0.0_rc8[${PYTHON_USEDEP}]
>=dev-python/tomli-1.0.0[${PYTHON_USEDEP}]
' 3.{9..10})
"
BDEPEND="
>=dev-python/setuptools-scm-6.2.3[${PYTHON_USEDEP}]
test? (
${RDEPEND}
$(python_gen_cond_dep '
dev-python/argcomplete[${PYTHON_USEDEP}]
>=dev-python/attrs-19.2.0[${PYTHON_USEDEP}]
>=dev-python/hypothesis-3.56[${PYTHON_USEDEP}]
dev-python/mock[${PYTHON_USEDEP}]
>=dev-python/pygments-2.7.2[${PYTHON_USEDEP}]
dev-python/pytest-xdist[${PYTHON_USEDEP}]
dev-python/requests[${PYTHON_USEDEP}]
dev-python/xmlschema[${PYTHON_USEDEP}]
' "${PYTHON_TESTED[@]}")
)
"
PATCHES=(
# https://github.com/pytest-dev/pytest/pull/11638
"${FILESDIR}/${P}-no-color.patch"
)
src_test() {
# workaround new readline defaults
echo "set enable-bracketed-paste off" > "${T}"/inputrc || die
local -x INPUTRC="${T}"/inputrc
distutils-r1_src_test
}
python_test() {
if ! has "${EPYTHON}" "${PYTHON_TESTED[@]/_/.}"; then
einfo "Skipping tests on ${EPYTHON}"
return
fi
local -x PYTEST_DISABLE_PLUGIN_AUTOLOAD=1
local -x COLUMNS=80
local EPYTEST_DESELECT=(
# broken by epytest args
testing/test_warnings.py::test_works_with_filterwarnings
# tend to be broken by random pytest plugins
# (these tests patch PYTEST_DISABLE_PLUGIN_AUTOLOAD out)
testing/test_helpconfig.py::test_version_less_verbose
testing/test_helpconfig.py::test_version_verbose
testing/test_junitxml.py::test_random_report_log_xdist
testing/test_junitxml.py::test_runs_twice_xdist
testing/test_terminal.py::TestProgressOutputStyle::test_xdist_normal
testing/test_terminal.py::TestProgressOutputStyle::test_xdist_normal_count
testing/test_terminal.py::TestProgressOutputStyle::test_xdist_verbose
testing/test_terminal.py::TestProgressWithTeardown::test_xdist_normal
testing/test_terminal.py::TestTerminalFunctional::test_header_trailer_info
testing/test_terminal.py::TestTerminalFunctional::test_no_header_trailer_info
# unstable with xdist
testing/test_terminal.py::TestTerminalFunctional::test_verbose_reporting_xdist
# TODO (XPASS)
testing/test_debugging.py::TestDebuggingBreakpoints::test_pdb_not_altered
testing/test_debugging.py::TestPDB::test_pdb_interaction_capturing_simple
testing/test_debugging.py::TestPDB::test_pdb_interaction_capturing_twice
testing/test_debugging.py::TestPDB::test_pdb_with_injected_do_debug
testing/test_debugging.py::test_pdb_suspends_fixture_capturing
# setuptools warnings
testing/acceptance_test.py::TestInvocationVariants::test_cmdline_python_namespace_package
)
[[ ${EPYTHON} == pypy3 ]] && EPYTEST_DESELECT+=(
# regressions on pypy3.9
# https://github.com/pytest-dev/pytest/issues/9787
testing/test_skipping.py::test_errors_in_xfail_skip_expressions
testing/test_unraisableexception.py
)
epytest -p xdist -n "$(makeopts_jobs)"
}