Compare commits
11 Commits
239def9be9
...
iqpilot
| Author | SHA1 | Date | |
|---|---|---|---|
|
23461ed23b
|
|||
|
|
2b4372bd62 | ||
|
|
1bb1a0f62a | ||
|
|
f8ea4a23b7 | ||
|
|
68bf76dce4 | ||
|
|
28c0a72e3a | ||
|
|
9d7dcae9d2 | ||
|
|
a3374b8d5c | ||
|
|
5824f221ca | ||
|
|
6ca0790e02 | ||
|
|
b59e010821 |
@@ -1,12 +1,12 @@
|
|||||||
[build-system]
|
[build-system]
|
||||||
requires = [
|
requires = [
|
||||||
"setuptools>=77.0",
|
"setuptools>=77.0",
|
||||||
"setuptools-scm[toml]>=6.2.3",
|
|
||||||
]
|
]
|
||||||
build-backend = "setuptools.build_meta"
|
build-backend = "setuptools.build_meta"
|
||||||
|
|
||||||
[project]
|
[project]
|
||||||
name = "pytest-xdist"
|
name = "pytest-xdist"
|
||||||
|
version = "3.7.1.dev24+g2b4372bd6"
|
||||||
description = "pytest xdist plugin for distributed testing, most importantly across multiple CPUs"
|
description = "pytest xdist plugin for distributed testing, most importantly across multiple CPUs"
|
||||||
readme = "README.rst"
|
readme = "README.rst"
|
||||||
license = "MIT"
|
license = "MIT"
|
||||||
@@ -35,7 +35,6 @@ dependencies = [
|
|||||||
"execnet>=2.1",
|
"execnet>=2.1",
|
||||||
"pytest>=7.0.0",
|
"pytest>=7.0.0",
|
||||||
]
|
]
|
||||||
dynamic = ["version"]
|
|
||||||
|
|
||||||
[project.urls]
|
[project.urls]
|
||||||
Homepage = "https://github.com/pytest-dev/pytest-xdist"
|
Homepage = "https://github.com/pytest-dev/pytest-xdist"
|
||||||
@@ -53,9 +52,6 @@ testing = ["filelock"]
|
|||||||
psutil = ["psutil>=3.0"]
|
psutil = ["psutil>=3.0"]
|
||||||
setproctitle = ["setproctitle"]
|
setproctitle = ["setproctitle"]
|
||||||
|
|
||||||
[tool.setuptools_scm]
|
|
||||||
write_to = "src/xdist/_version.py"
|
|
||||||
|
|
||||||
[tool.pytest.ini_options]
|
[tool.pytest.ini_options]
|
||||||
# pytest-services also defines a worker_id fixture, disable
|
# pytest-services also defines a worker_id fixture, disable
|
||||||
# it so they don't conflict with each other (#611).
|
# it so they don't conflict with each other (#611).
|
||||||
|
|||||||
@@ -1,10 +1,12 @@
|
|||||||
from xdist._version import version as __version__
|
|
||||||
from xdist.plugin import get_xdist_worker_id
|
from xdist.plugin import get_xdist_worker_id
|
||||||
from xdist.plugin import is_xdist_controller
|
from xdist.plugin import is_xdist_controller
|
||||||
from xdist.plugin import is_xdist_master
|
from xdist.plugin import is_xdist_master
|
||||||
from xdist.plugin import is_xdist_worker
|
from xdist.plugin import is_xdist_worker
|
||||||
|
|
||||||
|
|
||||||
|
__version__ = "3.7.1.dev24+g2b4372bd6"
|
||||||
|
|
||||||
|
|
||||||
__all__ = [
|
__all__ = [
|
||||||
"__version__",
|
"__version__",
|
||||||
"get_xdist_worker_id",
|
"get_xdist_worker_id",
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
from __future__ import annotations
|
from __future__ import annotations
|
||||||
|
|
||||||
from collections.abc import Sequence
|
from collections.abc import Sequence
|
||||||
|
from concurrent.futures import ThreadPoolExecutor
|
||||||
import enum
|
import enum
|
||||||
import fnmatch
|
import fnmatch
|
||||||
import os
|
import os
|
||||||
@@ -94,15 +95,23 @@ class NodeManager:
|
|||||||
) -> list[WorkerController]:
|
) -> list[WorkerController]:
|
||||||
self.config.hook.pytest_xdist_setupnodes(config=self.config, specs=self.specs)
|
self.config.hook.pytest_xdist_setupnodes(config=self.config, specs=self.specs)
|
||||||
self.trace("setting up nodes")
|
self.trace("setting up nodes")
|
||||||
return [self.setup_node(spec, putevent) for spec in self.specs]
|
with ThreadPoolExecutor(max_workers=len(self.specs)) as executor:
|
||||||
|
futs = [
|
||||||
|
executor.submit(self.setup_node, spec, putevent, idx)
|
||||||
|
for idx, spec in enumerate(self.specs)
|
||||||
|
]
|
||||||
|
return [f.result() for f in futs]
|
||||||
|
|
||||||
def setup_node(
|
def setup_node(
|
||||||
self,
|
self,
|
||||||
spec: execnet.XSpec,
|
spec: execnet.XSpec,
|
||||||
putevent: Callable[[tuple[str, dict[str, Any]]], None],
|
putevent: Callable[[tuple[str, dict[str, Any]]], None],
|
||||||
|
idx: int | None = None,
|
||||||
) -> WorkerController:
|
) -> WorkerController:
|
||||||
if getattr(spec, "execmodel", None) != "main_thread_only":
|
if getattr(spec, "execmodel", None) != "main_thread_only":
|
||||||
spec = execnet.XSpec(f"execmodel=main_thread_only//{spec}")
|
spec = execnet.XSpec(f"execmodel=main_thread_only//{spec}")
|
||||||
|
if idx is not None:
|
||||||
|
spec = execnet.XSpec(f"{spec}//id=gw{idx}")
|
||||||
gw = self.group.makegateway(spec)
|
gw = self.group.makegateway(spec)
|
||||||
self.config.hook.pytest_xdist_newgateway(gateway=gw)
|
self.config.hook.pytest_xdist_newgateway(gateway=gw)
|
||||||
self.rsync_roots(gw)
|
self.rsync_roots(gw)
|
||||||
|
|||||||
@@ -82,11 +82,19 @@ class TestNodeManagerPopen:
|
|||||||
call = hookrecorder.popcall("pytest_xdist_setupnodes")
|
call = hookrecorder.popcall("pytest_xdist_setupnodes")
|
||||||
assert len(call.specs) == 2
|
assert len(call.specs) == 2
|
||||||
|
|
||||||
call = hookrecorder.popcall("pytest_xdist_newgateway")
|
# check expected gateways
|
||||||
assert call.gateway.spec == execnet.XSpec("execmodel=main_thread_only//popen")
|
gw_calls = [
|
||||||
assert call.gateway.id == "gw0"
|
hookrecorder.popcall("pytest_xdist_newgateway"),
|
||||||
call = hookrecorder.popcall("pytest_xdist_newgateway")
|
hookrecorder.popcall("pytest_xdist_newgateway"),
|
||||||
assert call.gateway.id == "gw1"
|
]
|
||||||
|
assert {c.gateway.id for c in gw_calls} == {"gw0", "gw1"}
|
||||||
|
|
||||||
|
for c in gw_calls:
|
||||||
|
expected_spec = execnet.XSpec(
|
||||||
|
f"execmodel=main_thread_only//popen//id={c.gateway.id}"
|
||||||
|
)
|
||||||
|
assert c.gateway.spec == expected_spec
|
||||||
|
|
||||||
assert len(hm.group) == 2
|
assert len(hm.group) == 2
|
||||||
hm.teardown_nodes()
|
hm.teardown_nodes()
|
||||||
assert not len(hm.group)
|
assert not len(hm.group)
|
||||||
|
|||||||
Reference in New Issue
Block a user