How to run/call a plugin from another running plugin #11786
Unanswered
jeffwright13
asked this question in
Q&A
Replies: 1 comment
-
The built-in junitxml plugin is a good example of this pattern |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
I've got a pytest plugin (let's call it "pytest-a") that is working fine in its original form, invoked as
pytest --a
. I want to break this single, monolithic plugin into two separate and independent plugins: "pytest-a1" (which would basically do the initial pytest option-handling, file interfacing, input handling, etc.), and "pytest-a2" (the guts / main engine of the original plugin, where it handles all the test executions). I want this new guts-code to be able to be included/importable by other plugin code.The way I envision this working is, pytest-a1 will be called from the command line in the same way as pytest-a was before. Then after everything is set up, pytest-a1 will hand off its execution to pytest-a2. After pytest-a2 is done handling the tests and crunching data, pytest-a1 will take back over and complete the overall test execution (teardown, reporting, etc.). The overall effect will be as if I just invoked
pytest --a
on the command line. But now I have the added flexibility that I can write other "front end" plugin code that can call pytest-a2.My question is, how do I actually invoke pytest-a2's functionality from within pytest-a1 as it executes? Both pytest-a1 and pytest-a2 have their own command-line-options associated with them (
--a1
and--a2
), instead of the original monolithic plugin, which only had a single command-line option,--a
. What I want to be able to do is runpytest --a1
) and have it act as ifpytest --a1
andpytest_a2
are being called together, essentially providing the same functionality as if I were calling the originalpytest --a
.I hope this makes some sense. If not, I can get more concrete and point to the actual plugins' code.
Beta Was this translation helpful? Give feedback.
All reactions