Skip to content

Commit db57e8a

Browse files
authored
1 parent 259987e commit db57e8a

File tree

1 file changed

+8
-2
lines changed

1 file changed

+8
-2
lines changed

src/_pytest/config/argparsing.py

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -191,6 +191,8 @@ def addini(
191191
* ``linelist``: a list of strings, separated by line breaks
192192
* ``paths``: a list of :class:`pathlib.Path`, separated as in a shell
193193
* ``pathlist``: a list of ``py.path``, separated as in a shell
194+
* ``int``: an integer
195+
* ``float``: a floating-point number
194196
195197
For ``paths`` and ``pathlist`` types, they are considered relative to the ini-file.
196198
In case the execution is happening without an ini-file defined,
@@ -209,7 +211,7 @@ def addini(
209211
The value of ini-variables can be retrieved via a call to
210212
:py:func:`config.getini(name) <pytest.Config.getini>`.
211213
"""
212-
assert type in (None, "string", "paths", "pathlist", "args", "linelist", "bool")
214+
assert type in (None, "string", "paths", "pathlist", "args", "linelist", "bool", "int", "float")
213215
if default is NOT_SET:
214216
default = get_ini_default_for_type(type)
215217

@@ -218,7 +220,7 @@ def addini(
218220

219221

220222
def get_ini_default_for_type(
221-
type: Literal["string", "paths", "pathlist", "args", "linelist", "bool"] | None,
223+
type: Literal["string", "paths", "pathlist", "args", "linelist", "bool", "int", "float"] | None,
222224
) -> Any:
223225
"""
224226
Used by addini to get the default value for a given ini-option type, when
@@ -230,6 +232,10 @@ def get_ini_default_for_type(
230232
return []
231233
elif type == "bool":
232234
return False
235+
elif type == "int":
236+
return 0
237+
elif type == "float":
238+
return 0.0
233239
else:
234240
return ""
235241

0 commit comments

Comments
 (0)