[pytest-dev] question about pytest_addoption
bryan.berry at gmail.com
Sun Feb 28 14:21:29 EST 2016
dear pytest folks,
I am creating an automation framework based on pytest for my employer that i
hope to someday soon open-source. This framework is tentatively titled
'Ghost-elephant' after my child's imaginary friend. At a 5,000 foot view my
ghost-elephant manages virtual machines and a bag of configuration
to execute the tests.
Ghost-elephant adds some custom command-line options but I also want to also
allow libraries, say added by separate fixture libraries, to add
flags. For example, Ghost-elephant adds a flag --skip-cleanup that my
fixtures use to determine if the fixture's cleanup step should be skipped.
A specific fixture library, say foo_fixture that handles the installation
of some particularly hairy proprietary software, may want to add additional
custom options. Perhaps, we need to pass this fixture a special flag
to enable ipv6 support.
Here is how I have currently attempted to support this feature and it isn't
at all. Could anyone point me towards a working solution?
I really want to minimize the code that a user needs to add to their
contest.py to take advantage of this.
parser.addoption('--ipv6', action='store_true', default=False)
ipv6 = request.config.getoption('--ipv6')
# lots of complicated stuff
option_adders = 
gs = globals()
for g in gs.keys():
if isinstance(gs[g], function) and
for o in option_adders:
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the pytest-dev