Parser.addini() can take and defaults to 'string'

This commit is contained in:
Kyle Altendorf 2020-10-07 17:21:55 -04:00
parent 95917f8833
commit af3759a503
1 changed files with 7 additions and 4 deletions

View File

@ -160,20 +160,23 @@ class Parser:
self, self,
name: str, name: str,
help: str, help: str,
type: Optional["Literal['pathlist', 'args', 'linelist', 'bool']"] = None, type: Optional[
"Literal['string', 'pathlist', 'args', 'linelist', 'bool']"
] = None,
default=None, default=None,
) -> None: ) -> None:
"""Register an ini-file option. """Register an ini-file option.
:name: Name of the ini-variable. :name: Name of the ini-variable.
:type: Type of the variable, can be ``pathlist``, ``args``, ``linelist`` :type: Type of the variable, can be ``string``, ``pathlist``, ``args``,
or ``bool``. ``linelist`` or ``bool``. Defaults to ``string`` if ``None`` or
not passed.
:default: Default value if no ini-file option exists but is queried. :default: Default value if no ini-file option exists but is queried.
The value of ini-variables can be retrieved via a call to The value of ini-variables can be retrieved via a call to
:py:func:`config.getini(name) <_pytest.config.Config.getini>`. :py:func:`config.getini(name) <_pytest.config.Config.getini>`.
""" """
assert type in (None, "pathlist", "args", "linelist", "bool") assert type in (None, "string", "pathlist", "args", "linelist", "bool")
self._inidict[name] = (help, type, default) self._inidict[name] = (help, type, default)
self._ininames.append(name) self._ininames.append(name)