Merge pull request #7356 from Zac-HD/emancipate

Finish deprecation of "slave"
This commit is contained in:
Zac Hatfield-Dodds 2020-06-12 23:13:11 +10:00 committed by GitHub
commit 0f30103d9c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
12 changed files with 29 additions and 28 deletions

View File

@ -0,0 +1 @@
Remove last internal uses of deprecated "slave" term from old pytest-xdist.

View File

@ -46,7 +46,7 @@ Changes between 2.3.4 and 2.3.5
- Issue 265 - integrate nose setup/teardown with setupstate
so it doesn't try to teardown if it did not setup
- issue 271 - don't write junitxml on slave nodes
- issue 271 - don't write junitxml on worker nodes
- Issue 274 - don't try to show full doctest example
when doctest does not know the example location

View File

@ -32,7 +32,7 @@ Changes 2.6.1
purely the nodeid. The line number is still shown in failure reports.
Thanks Floris Bruynooghe.
- fix issue437 where assertion rewriting could cause pytest-xdist slaves
- fix issue437 where assertion rewriting could cause pytest-xdist worker nodes
to collect different tests. Thanks Bruno Oliveira.
- fix issue555: add "errors" attribute to capture-streams to satisfy

View File

@ -6159,7 +6159,7 @@ time or change existing behaviors in order to make them less surprising/more use
purely the nodeid. The line number is still shown in failure reports.
Thanks Floris Bruynooghe.
- fix issue437 where assertion rewriting could cause pytest-xdist slaves
- fix issue437 where assertion rewriting could cause pytest-xdist worker nodes
to collect different tests. Thanks Bruno Oliveira.
- fix issue555: add "errors" attribute to capture-streams to satisfy
@ -6706,7 +6706,7 @@ Bug fixes:
- Issue 265 - integrate nose setup/teardown with setupstate
so it doesn't try to teardown if it did not setup
- issue 271 - don't write junitxml on slave nodes
- issue 271 - don't write junitxml on worker nodes
- Issue 274 - don't try to show full doctest example
when doctest does not know the example location
@ -7588,7 +7588,7 @@ Bug fixes:
- fix assert reinterpreation that sees a call containing "keyword=..."
- fix issue66: invoke pytest_sessionstart and pytest_sessionfinish
hooks on slaves during dist-testing, report module/session teardown
hooks on worker nodes during dist-testing, report module/session teardown
hooks correctly.
- fix issue65: properly handle dist-testing if no

View File

@ -170,7 +170,7 @@ several problems:
1. in distributed testing the master process would setup test resources
that are never needed because it only co-ordinates the test run
activities of the slave processes.
activities of the worker processes.
2. if you only perform a collection (with "--collect-only")
resource-setup will still be executed.

View File

@ -341,7 +341,7 @@ class LFPlugin:
def pytest_sessionfinish(self, session: Session) -> None:
config = self.config
if config.getoption("cacheshow") or hasattr(config, "slaveinput"):
if config.getoption("cacheshow") or hasattr(config, "workerinput"):
return
assert config.cache is not None
@ -386,7 +386,7 @@ class NFPlugin:
def pytest_sessionfinish(self) -> None:
config = self.config
if config.getoption("cacheshow") or hasattr(config, "slaveinput"):
if config.getoption("cacheshow") or hasattr(config, "workerinput"):
return
if config.getoption("collectonly"):

View File

@ -427,8 +427,8 @@ def pytest_addoption(parser: Parser) -> None:
def pytest_configure(config: Config) -> None:
xmlpath = config.option.xmlpath
# prevent opening xmllog on slave nodes (xdist)
if xmlpath and not hasattr(config, "slaveinput"):
# prevent opening xmllog on worker nodes (xdist)
if xmlpath and not hasattr(config, "workerinput"):
junit_family = config.getini("junit_family")
if not junit_family:
_issue_warning_captured(deprecated.JUNIT_XML_DEFAULT_FAMILY, config.hook, 2)
@ -506,17 +506,17 @@ class LogXML:
def finalize(self, report: TestReport) -> None:
nodeid = getattr(report, "nodeid", report)
# local hack to handle xdist report order
slavenode = getattr(report, "node", None)
reporter = self.node_reporters.pop((nodeid, slavenode))
workernode = getattr(report, "node", None)
reporter = self.node_reporters.pop((nodeid, workernode))
if reporter is not None:
reporter.finalize()
def node_reporter(self, report: Union[TestReport, str]) -> _NodeReporter:
nodeid = getattr(report, "nodeid", report) # type: Union[str, TestReport]
# local hack to handle xdist report order
slavenode = getattr(report, "node", None)
workernode = getattr(report, "node", None)
key = nodeid, slavenode
key = nodeid, workernode
if key in self.node_reporters:
# TODO: breaks for --dist=each

View File

@ -33,7 +33,7 @@ def pytest_configure(config: Config) -> None:
if config.option.pastebin == "all":
tr = config.pluginmanager.getplugin("terminalreporter")
# if no terminal reporter plugin is present, nothing we can do here;
# this can happen when this function executes in a slave node
# this can happen when this function executes in a worker node
# when using pytest-xdist, for example
if tr is not None:
# pastebin file will be utf-8 encoded binary file

View File

@ -38,13 +38,13 @@ if TYPE_CHECKING:
from _pytest.runner import CallInfo
def getslaveinfoline(node):
def getworkerinfoline(node):
try:
return node._slaveinfocache
return node._workerinfocache
except AttributeError:
d = node.slaveinfo
d = node.workerinfo
ver = "%s.%s.%s" % d["version_info"][:3]
node._slaveinfocache = s = "[{}] {} -- Python {} {}".format(
node._workerinfocache = s = "[{}] {} -- Python {} {}".format(
d["id"], d["sysplatform"], ver, d["executable"]
)
return s
@ -71,7 +71,7 @@ class BaseReport:
def toterminal(self, out) -> None:
if hasattr(self, "node"):
out.line(getslaveinfoline(self.node))
out.line(getworkerinfoline(self.node))
longrepr = self.longrepr
if longrepr is None:

View File

@ -29,8 +29,8 @@ def pytest_addoption(parser: Parser) -> None:
def pytest_configure(config: Config) -> None:
resultlog = config.option.resultlog
# prevent opening resultlog on slave nodes (xdist)
if resultlog and not hasattr(config, "slaveinput"):
# prevent opening resultlog on worker nodes (xdist)
if resultlog and not hasattr(config, "workerinput"):
dirname = os.path.dirname(os.path.abspath(resultlog))
if not os.path.isdir(dirname):
os.makedirs(dirname)

View File

@ -866,12 +866,12 @@ def test_mangle_test_address():
assert newnames == ["a.my.py.thing", "Class", "method", "[a-1-::]"]
def test_dont_configure_on_slaves(tmpdir) -> None:
def test_dont_configure_on_workers(tmpdir) -> None:
gotten = [] # type: List[object]
class FakeConfig:
if TYPE_CHECKING:
slaveinput = None
workerinput = None
def __init__(self):
self.pluginmanager = self
@ -891,7 +891,7 @@ def test_dont_configure_on_slaves(tmpdir) -> None:
junitxml.pytest_configure(fake_config)
assert len(gotten) == 1
FakeConfig.slaveinput = None
FakeConfig.workerinput = None
junitxml.pytest_configure(fake_config)
assert len(gotten) == 1
@ -1250,7 +1250,7 @@ def test_record_fixtures_xunit2(testdir, fixture_name, run_and_parse):
def test_random_report_log_xdist(testdir, monkeypatch, run_and_parse):
"""xdist calls pytest_runtest_logreport as they are executed by the slaves,
"""xdist calls pytest_runtest_logreport as they are executed by the workers,
with nodes from several nodes overlapping, so junitxml must cope with that
to produce correct reports. #1064
"""

View File

@ -177,7 +177,7 @@ def test_makedir_for_resultlog(testdir, LineMatcher):
LineMatcher(lines).fnmatch_lines([". *:test_pass"])
def test_no_resultlog_on_slaves(testdir):
def test_no_resultlog_on_workers(testdir):
config = testdir.parseconfig("-p", "resultlog", "--resultlog=resultlog")
assert resultlog_key not in config._store
@ -186,7 +186,7 @@ def test_no_resultlog_on_slaves(testdir):
pytest_unconfigure(config)
assert resultlog_key not in config._store
config.slaveinput = {}
config.workerinput = {}
pytest_configure(config)
assert resultlog_key not in config._store
pytest_unconfigure(config)