@@ -70,6 +70,8 @@ def main(args=None, plugins=None):
7070 tw .line (line .rstrip (), red = True )
7171 return 4
7272 else :
73+ config .invocation_args = args
74+ config .invocation_plugins = plugins
7375 try :
7476 return config .hook .pytest_cmdline_main (config = config )
7577 finally :
@@ -608,20 +610,33 @@ def _iter_rewritable_modules(package_files):
608610
609611
610612class Config :
611- """ access to configuration values, pluginmanager and plugin hooks. """
613+ """
614+ Access to configuration values, pluginmanager and plugin hooks.
615+
616+ :ivar PytestPluginManager pluginmanager: the plugin manager handles plugin registration and hook invocation.
617+
618+ :ivar argparse.Namespace option: access to command line option as attributes.
619+
620+ :ivar invocation_args: list of command-line arguments as passed to pytest.main()
621+
622+ :ivar invocation_plugins: list of extra plugins passed to pytest.main(), might be None
623+
624+ :ivar py.path.local invocation_dir: directory where pytest.main() was invoked from
625+ """
612626
613627 def __init__ (self , pluginmanager ):
614- #: access to command line option as attributes.
615- #: (deprecated), use :py:func:`getoption() <_pytest.config.Config.getoption>` instead
616- self .option = argparse .Namespace ()
617628 from .argparsing import Parser , FILE_OR_DIR
618629
630+ self .option = argparse .Namespace ()
631+ self .invocation_args = None
632+ self .invocation_plugins = None
633+ self .invocation_dir = py .path .local ()
634+
619635 _a = FILE_OR_DIR
620636 self ._parser = Parser (
621637 usage = "%(prog)s [options] [{}] [{}] [...]" .format (_a , _a ),
622638 processopt = self ._processopt ,
623639 )
624- #: a pluginmanager instance
625640 self .pluginmanager = pluginmanager
626641 self .trace = self .pluginmanager .trace .root .get ("config" )
627642 self .hook = self .pluginmanager .hook
@@ -631,7 +646,6 @@ def __init__(self, pluginmanager):
631646 self ._cleanup = []
632647 self .pluginmanager .register (self , "pytestconfig" )
633648 self ._configured = False
634- self .invocation_dir = py .path .local ()
635649 self .hook .pytest_addoption .call_historic (kwargs = dict (parser = self ._parser ))
636650
637651 def add_cleanup (self , func ):
0 commit comments