Skip to content

Commit

Permalink
Merge pull request #7356 from Zac-HD/emancipate
Browse files Browse the repository at this point in the history
Finish deprecation of "slave"
  • Loading branch information
Zac-HD committed Jun 12, 2020
2 parents 72344a5 + 564b2f7 commit 0f30103
Show file tree
Hide file tree
Showing 12 changed files with 29 additions and 28 deletions.
1 change: 1 addition & 0 deletions changelog/7356.trivial.rst
@@ -0,0 +1 @@
Remove last internal uses of deprecated "slave" term from old pytest-xdist.
2 changes: 1 addition & 1 deletion doc/en/announce/release-2.3.5.rst
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion doc/en/announce/release-2.6.1.rst
Expand Up @@ -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
Expand Down
6 changes: 3 additions & 3 deletions doc/en/changelog.rst
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion doc/en/funcarg_compare.rst
Expand Up @@ -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.
Expand Down
4 changes: 2 additions & 2 deletions src/_pytest/cacheprovider.py
Expand Up @@ -341,7 +341,7 @@ def pytest_collection_modifyitems(

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
Expand Down Expand Up @@ -386,7 +386,7 @@ def _get_increasing_order(self, items: Iterable[nodes.Item]) -> List[nodes.Item]

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"):
Expand Down
12 changes: 6 additions & 6 deletions src/_pytest/junitxml.py
Expand Up @@ -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)
Expand Down Expand Up @@ -506,17 +506,17 @@ def __init__(
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
Expand Down
2 changes: 1 addition & 1 deletion src/_pytest/pastebin.py
Expand Up @@ -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
Expand Down
10 changes: 5 additions & 5 deletions src/_pytest/reports.py
Expand Up @@ -38,13 +38,13 @@
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
Expand All @@ -71,7 +71,7 @@ def __getattr__(self, key: str) -> Any:

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:
Expand Down
4 changes: 2 additions & 2 deletions src/_pytest/resultlog.py
Expand Up @@ -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)
Expand Down
8 changes: 4 additions & 4 deletions testing/test_junitxml.py
Expand Up @@ -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
Expand All @@ -891,7 +891,7 @@ def getini(self, name):

junitxml.pytest_configure(fake_config)
assert len(gotten) == 1
FakeConfig.slaveinput = None
FakeConfig.workerinput = None
junitxml.pytest_configure(fake_config)
assert len(gotten) == 1

Expand Down Expand Up @@ -1250,7 +1250,7 @@ def test_record({fixture_name}, other):


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
"""
Expand Down
4 changes: 2 additions & 2 deletions testing/test_resultlog.py
Expand Up @@ -177,7 +177,7 @@ def test_pass():
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
Expand All @@ -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)
Expand Down

0 comments on commit 0f30103

Please sign in to comment.