Hello, I'm working on a custom (private) plugin vary tailored to our product. The plugin adapts its feature set based on the abilities of the internal server it connects to. I was thinking of implementing an option in my plugin, e.g. `--show-our-superduper-help`. This could go out to the server, fetch it's config and print the abilities which can be used in the test suite for that server. I looked at how the regular `--help` is implemented: https://github.com/pytest-dev/pytest/blob/71a7b3c062d51c61ee8b1ac479b1260d54... It uses the HelpAction which raises a PrintHelp exception to shortcut on running the test suite. Not really fond of implementing something similar. How could I get a similar behaviour for only printing the (server specific) config of my plugin? Thanks, *Ringo De Smet* ringo.de.smet@ontoforce.com
Hi Ringo, On Wed, Apr 04 2018, Ringo De Smet wrote:
I was thinking of implementing an option in my plugin, e.g. `--show-our-superduper-help`. This could go out to the server, fetch it's config and print the abilities which can be used in the test suite for that server.
I looked at how the regular `--help` is implemented:
https://github.com/pytest-dev/pytest/blob/71a7b3c062d51c61ee8b1ac479b1260d54...
It uses the HelpAction which raises a PrintHelp exception to shortcut on running the test suite.
Not really fond of implementing something similar. How could I get a similar behaviour for only printing the (server specific) config of my plugin?
You could look at how --fixtures is implemented, that's probably what I would follow if I wanted to do something similar. Search for "showfixtures" in _pytest/python.py. Basically add the option like normal in pytest_addoption() and then implement pytest_cmdline_main() to look for the option and handle it. If the option is not there just return None from it and the normal pytest will continue to run. Hope that helps, Floris
participants (2)
-
Floris Bruynooghe -
Ringo De Smet