Bump min pytest to 7.0.0

Refs #1057
This commit is contained in:
Ran Benita
2024-04-04 19:52:09 +03:00
parent 99b767b6dd
commit 31de42ffa5
15 changed files with 40 additions and 56 deletions

View File

@@ -206,9 +206,7 @@ class DSession:
try:
assert False, formatted_error
except AssertionError:
from _pytest._code import ExceptionInfo
excinfo = ExceptionInfo.from_current()
excinfo = pytest.ExceptionInfo.from_current()
excrepr = excinfo.getrepr()
self.config.hook.pytest_internalerror(excrepr=excrepr, excinfo=excinfo)

View File

@@ -168,7 +168,7 @@ def init_worker_session(channel, args, option_dict):
sys.path[:] = newpaths
# fullwidth, hasmarkup = channel.receive()
from _pytest.config import Config
from pytest import Config
config = Config.fromdictargs(option_dict, list(args))
config.args = args

View File

@@ -6,8 +6,6 @@ import warnings
import pytest
PYTEST_GTE_7 = hasattr(pytest, "version_tuple") and pytest.version_tuple >= (7, 0) # type: ignore[attr-defined]
_sys_path = list(sys.path) # freeze a copy of sys.path at interpreter startup
@@ -188,16 +186,16 @@ def pytest_addoption(parser):
parser.addini(
"rsyncdirs",
"list of (relative) paths to be rsynced for remote distributed testing.",
type="paths" if PYTEST_GTE_7 else "pathlist",
type="paths",
)
parser.addini(
"rsyncignore",
"list of (relative) glob-style paths to be ignored for rsyncing.",
type="paths" if PYTEST_GTE_7 else "pathlist",
type="paths",
)
parser.addini(
"looponfailroots",
type="paths" if PYTEST_GTE_7 else "pathlist",
type="paths",
help="directories to check for changes. Default: current directory.",
)

View File

@@ -201,14 +201,9 @@ class WorkerInteractor:
@pytest.hookimpl
def pytest_collection_finish(self, session):
try:
topdir = str(self.config.rootpath)
except AttributeError: # pytest <= 6.1.0
topdir = str(self.config.rootdir)
self.sendevent(
"collectionfinish",
topdir=topdir,
topdir=str(self.config.rootpath),
ids=[item.nodeid for item in session.items],
)

View File

@@ -1,6 +1,6 @@
from itertools import cycle
from _pytest.runner import CollectReport
import pytest
from xdist.remote import Producer
from xdist.report import report_collection_diff
@@ -307,8 +307,11 @@ class LoadScheduling:
same_collection = False
self.log(msg)
if self.config is not None:
rep = CollectReport(
node.gateway.id, "failed", longrepr=msg, result=[]
rep = pytest.CollectReport(
nodeid=node.gateway.id,
outcome="failed",
longrepr=msg,
result=[],
)
self.config.hook.pytest_collectreport(report=rep)

View File

@@ -1,6 +1,6 @@
from collections import OrderedDict
from _pytest.runner import CollectReport
import pytest
from xdist.remote import Producer
from xdist.report import report_collection_diff
@@ -410,7 +410,12 @@ class LoadScopeScheduling:
if self.config is None:
continue
rep = CollectReport(node.gateway.id, "failed", longrepr=msg, result=[])
rep = pytest.CollectReport(
nodeid=node.gateway.id,
outcome="failed",
longrepr=msg,
result=[],
)
self.config.hook.pytest_collectreport(report=rep)
return same_collection

View File

@@ -3,7 +3,7 @@ from __future__ import annotations
from typing import Any
from typing import NamedTuple
from _pytest.runner import CollectReport
import pytest
from xdist.remote import Producer
from xdist.report import report_collection_diff
@@ -323,8 +323,11 @@ class WorkStealingScheduling:
same_collection = False
self.log(msg)
if self.config is not None:
rep = CollectReport(
node.gateway.id, "failed", longrepr=msg, result=[]
rep = pytest.CollectReport(
nodeid=node.gateway.id,
outcome="failed",
longrepr=msg,
result=[],
)
self.config.hook.pytest_collectreport(report=rep)

View File

@@ -401,9 +401,7 @@ class WorkerController:
# should not land in receiver-thread
raise
except BaseException:
from _pytest._code import ExceptionInfo
excinfo = ExceptionInfo.from_current()
excinfo = pytest.ExceptionInfo.from_current()
print("!" * 20, excinfo)
self.config.notify_exception(excinfo)
self.shutdown()