Skip to content

Commit 8a00dcc

Browse files
committed
WIP play around with config initialization
While investigating a recent node id bug (#445) I decided to play with config initialization around the idea of initializing the config on the remote *exactly* we initialize the config object on pytest.main() One thing that immediately broke all tests was inprocess pytester runs, but other than that just a few tests failed which I find encouraging. While this patch is in no way even remotely ready, I would like to get opinions if the overall idea of initializing the config object like this is sound.
1 parent a19d74d commit 8a00dcc

File tree

3 files changed

+9
-11
lines changed

3 files changed

+9
-11
lines changed

src/xdist/remote.py

+6-8
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,8 @@
1515
import pytest
1616
from execnet.gateway_base import dumps, DumpError
1717

18+
from _pytest.config import _prepareconfig
19+
1820

1921
class WorkerInteractor(object):
2022
def __init__(self, config, channel):
@@ -210,19 +212,14 @@ def getinfodict():
210212
)
211213

212214

213-
def remote_initconfig(option_dict, args):
214-
from _pytest.config import Config
215-
216-
option_dict["plugins"].append("no:terminal")
217-
config = Config.fromdictargs(option_dict, args)
215+
def remote_initconfig(config, option_dict):
218216
config.option.looponfail = False
219217
config.option.usepdb = False
220218
config.option.dist = "no"
221219
config.option.distload = False
222220
config.option.numprocesses = None
223221
config.option.maxprocesses = None
224-
config.args = args
225-
return config
222+
config.option.basetemp = option_dict.get('basetemp')
226223

227224

228225
if __name__ == "__channelexec__":
@@ -239,7 +236,8 @@ def remote_initconfig(option_dict, args):
239236
os.environ["PYTEST_XDIST_WORKER"] = workerinput["workerid"]
240237
os.environ["PYTEST_XDIST_WORKER_COUNT"] = str(workerinput["workercount"])
241238

242-
config = remote_initconfig(option_dict, args)
239+
config = _prepareconfig(args, None)
240+
remote_initconfig(config, option_dict)
243241
config._parser.prog = os.path.basename(workerinput["mainargv"][0])
244242
config.workerinput = workerinput
245243
config.workeroutput = {}

src/xdist/workermanage.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -236,10 +236,10 @@ def shutting_down(self):
236236
def setup(self):
237237
self.log("setting up worker session")
238238
spec = self.gateway.spec
239-
args = self.config.args
239+
args = sys.argv[1:]
240240
if not spec.popen or spec.chdir:
241241
args = make_reltoroot(self.nodemanager.roots, args)
242-
option_dict = vars(self.config.option)
242+
option_dict = {}
243243
if spec.popen:
244244
name = "popen-%s" % self.gateway.id
245245
if hasattr(self.config, "_tmpdirhandler"):

tox.ini

+1-1
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ deps =
1212
pytestmaster: git+https://github.com/pytest-dev/pytest.git@master
1313
pytestfeatures: git+https://github.com/pytest-dev/pytest.git@features
1414
commands=
15-
pytest {posargs}
15+
pytest {posargs} --runpytest=subprocess
1616

1717
[testenv:linting]
1818
skipsdist = True

0 commit comments

Comments
 (0)