31
31
from _pytest .pytester import Pytester
32
32
33
33
34
+ setup_cfg_nowarn = pytest .mark .filterwarnings (
35
+ "ignore:.*setup.cfg.*:pytest.PytestDeprecationWarning"
36
+ )
37
+
38
+
34
39
class TestParseIni :
35
40
@pytest .mark .parametrize (
36
- "section, filename" , [("pytest" , "pytest.ini" ), ("tool:pytest" , "setup.cfg" )]
41
+ "section, filename" ,
42
+ [
43
+ ("pytest" , "pytest.ini" ),
44
+ pytest .param ("tool:pytest" , "setup.cfg" , marks = setup_cfg_nowarn ),
45
+ ],
37
46
)
38
47
def test_getcfg_and_config (
39
48
self ,
@@ -62,6 +71,7 @@ def test_getcfg_and_config(
62
71
config = pytester .parseconfigure (str (sub ))
63
72
assert config .inicfg ["name" ] == "value"
64
73
74
+ @setup_cfg_nowarn
65
75
def test_setupcfg_uses_toolpytest_with_pytest (self , pytester : Pytester ) -> None :
66
76
p1 = pytester .makepyfile ("def test(): pass" )
67
77
pytester .makefile (
@@ -112,7 +122,11 @@ def test_tox_ini_wrong_version(self, pytester: Pytester) -> None:
112
122
113
123
@pytest .mark .parametrize (
114
124
"section, name" ,
115
- [("tool:pytest" , "setup.cfg" ), ("pytest" , "tox.ini" ), ("pytest" , "pytest.ini" )],
125
+ [
126
+ pytest .param ("tool:pytest" , "setup.cfg" , marks = setup_cfg_nowarn ),
127
+ ("pytest" , "tox.ini" ),
128
+ ("pytest" , "pytest.ini" ),
129
+ ],
116
130
)
117
131
def test_ini_names (self , pytester : Pytester , name , section ) -> None :
118
132
pytester .path .joinpath (name ).write_text (
@@ -1311,7 +1325,12 @@ def test_simple_noini(self, tmp_path: Path, monkeypatch: MonkeyPatch) -> None:
1311
1325
"pyproject.toml" , "[tool.pytest.ini_options]\n x=10" , id = "pyproject.toml"
1312
1326
),
1313
1327
pytest .param ("tox.ini" , "[pytest]\n x=10" , id = "tox.ini" ),
1314
- pytest .param ("setup.cfg" , "[tool:pytest]\n x=10" , id = "setup.cfg" ),
1328
+ pytest .param (
1329
+ "setup.cfg" ,
1330
+ "[tool:pytest]\n x=10" ,
1331
+ id = "setup.cfg" ,
1332
+ marks = setup_cfg_nowarn ,
1333
+ ),
1315
1334
],
1316
1335
)
1317
1336
def test_with_ini (self , tmp_path : Path , name : str , contents : str ) -> None :
@@ -1424,6 +1443,7 @@ def test_with_existing_file_in_subdir(
1424
1443
assert rootpath == tmp_path
1425
1444
assert inipath is None
1426
1445
1446
+ @setup_cfg_nowarn
1427
1447
def test_with_config_also_in_parent_directory (
1428
1448
self , tmp_path : Path , monkeypatch : MonkeyPatch
1429
1449
) -> None :
@@ -1441,7 +1461,10 @@ def test_with_config_also_in_parent_directory(
1441
1461
1442
1462
1443
1463
class TestOverrideIniArgs :
1444
- @pytest .mark .parametrize ("name" , "setup.cfg tox.ini pytest.ini" .split ())
1464
+ @pytest .mark .parametrize (
1465
+ "name" ,
1466
+ [pytest .param ("setup.cfg" , marks = setup_cfg_nowarn ), "tox.ini" , "pytest.ini" ],
1467
+ )
1445
1468
def test_override_ini_names (self , pytester : Pytester , name : str ) -> None :
1446
1469
section = "[pytest]" if name != "setup.cfg" else "[tool:pytest]"
1447
1470
pytester .path .joinpath (name ).write_text (
0 commit comments