Fix 13314 add all plugins to pytester subprocess#13316
Fix 13314 add all plugins to pytester subprocess#13316Faboor wants to merge 7 commits intopytest-dev:mainfrom
Conversation
The-Compiler
left a comment
There was a problem hiding this comment.
Seems reasonable! Just one question that doesn't seem clear at first sight.
src/_pytest/pytester.py
Outdated
| plugins = [x for x in self.plugins if isinstance(x, str)] | ||
| if plugins: | ||
| args = ("-p", plugins[0], *args) | ||
| for plugin in reversed(plugins): |
There was a problem hiding this comment.
The plugins args get prepended to existing args, so I've used reversed(...) to make sure that the CLI args -p plugin_1 -p plugin_2 are in the same order as in pytester.plugins. I don't think it functionally matters, but just in case.
And I like the direct mapping from ["plugin_1", "plugin_2"] -> -p plugin_1 -p plugin_2 much more than the alternative.
There was a problem hiding this comment.
Ah, right, that makes sense now. I'm not a fan of the complexity of keeping args a tuple and all the prepending, personally I'd probably do something like (untested):
__tracebackhide__ = True
p = make_numbered_dir(root=self.path, prefix="runpytest-", mode=0o700)
pytest_args = list(self._getpytestargs())
for plugin in self.plugins:
if isinstance(plugin, str):
pytest_args += ["-p", plugin]
pytest_args.append("--basetemp={p}")
pytest_args += list(args)
return self.run(*pytest_args, timeout=timeout)which seems far more readable to me.
However, you're just keeping the existing style here, so I don't think this should block this PR.
a9f961f to
d6d5866
Compare
d6d5866 to
5c5926b
Compare
|
Thanks @Faboor! As commented in #13522 (comment), this PR slipped through the cracks and ended up not merged. Sorry again! |
Closes #13314
closes #XYZWto the PR description and/or commits (whereXYZWis the issue number). See the github docs for more information.changelogfolder, with a name like<ISSUE NUMBER>.<TYPE>.rst. See changelog/README.rst for details.AUTHORSin alphabetical order.Running the same minimal example from #13314:
Testing
Running the new test without 072bd1e using
pytest -v testing/test_pytester.py::test_pytester_subprocess_with_pluginsand with the change: