Sanitized the handling of the default
parameter when defining configuration options.
Previously if default
was not supplied for parser.addini <pytest.Parser.addini>
and the configuration option value was not defined in a test session, then calls to config.getini <pytest.Config.getini>
returned an empty list or an empty string depending on whether type
was supplied or not respectively, which is clearly incorrect. Also, None
was not honored even if default=None
was used explicitly while defining the option.
Now the behavior of parser.addini <pytest.Parser.addini>
is as follows:
- If
default
is NOT passed buttype
is provided, then a type-specific default will be returned. For exampletype=bool
will returnFalse
,type=str
will return""
, etc. - If
default=None
is passed and the option is not defined in a test session, thenNone
will be returned, regardless of thetype
. - If neither
default
nortype
are provided, assumetype=str
and return""
as default (this is as per previous behavior).
The team decided to not introduce a deprecation period for this change, as doing so would be complicated both in terms of communicating this to the community as well as implementing it, and also because the team believes this change should not break existing plugins except in rare cases.