File tree 4 files changed +28
-3
lines changed
4 files changed +28
-3
lines changed Original file line number Diff line number Diff line change
1
+ When using ``--override-ini `` for paths in invocations without a configuration file defined, the current working directory is used
2
+ as the relative directory.
3
+
4
+ Previoulsy this would raise an :class: `AssertionError `.
Original file line number Diff line number Diff line change @@ -1563,9 +1563,11 @@ def _getini(self, name: str):
1563
1563
# in this case, we already have a list ready to use.
1564
1564
#
1565
1565
if type == "paths" :
1566
- # TODO: This assert is probably not valid in all cases.
1567
- assert self .inipath is not None
1568
- dp = self .inipath .parent
1566
+ dp = (
1567
+ self .inipath .parent
1568
+ if self .inipath is not None
1569
+ else self .invocation_params .dir
1570
+ )
1569
1571
input_values = shlex .split (value ) if isinstance (value , str ) else value
1570
1572
return [dp / x for x in input_values ]
1571
1573
elif type == "args" :
Original file line number Diff line number Diff line change @@ -198,9 +198,16 @@ def addini(
198
198
* ``paths``: a list of :class:`pathlib.Path`, separated as in a shell
199
199
* ``pathlist``: a list of ``py.path``, separated as in a shell
200
200
201
+ For ``paths`` and ``pathlist`` types, they are considered relative to the ini-file.
202
+ In case the execution is happening without an ini-file defined,
203
+ they will be considered relative to the current working directory (for example with ``--override-ini``).
204
+
201
205
.. versionadded:: 7.0
202
206
The ``paths`` variable type.
203
207
208
+ .. versionadded:: 8.1
209
+ Use the current working directory to resolve ``paths`` and ``pathlist`` in the absence of an ini-file.
210
+
204
211
Defaults to ``string`` if ``None`` or not passed.
205
212
:param default:
206
213
Default value if no ini-file option exists but is queried.
Original file line number Diff line number Diff line change @@ -1874,6 +1874,18 @@ def test():
1874
1874
assert "ERROR:" not in result .stderr .str ()
1875
1875
result .stdout .fnmatch_lines (["collected 1 item" , "*= 1 passed in *=" ])
1876
1876
1877
+ def test_override_ini_without_config_file (self , pytester : Pytester ) -> None :
1878
+ pytester .makepyfile (** {"src/override_ini_without_config_file.py" : "" })
1879
+ pytester .makepyfile (
1880
+ ** {
1881
+ "tests/test_override_ini_without_config_file.py" : (
1882
+ "import override_ini_without_config_file\n def test(): pass"
1883
+ ),
1884
+ }
1885
+ )
1886
+ result = pytester .runpytest ("--override-ini" , "pythonpath=src" )
1887
+ assert result .parseoutcomes () == {"passed" : 1 }
1888
+
1877
1889
1878
1890
def test_help_via_addopts (pytester : Pytester ) -> None :
1879
1891
pytester .makeini (
You can’t perform that action at this time.
0 commit comments