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 (
@@ -1331,7 +1345,12 @@ def test_simple_noini(self, tmp_path: Path, monkeypatch: MonkeyPatch) -> None:
1331
1345
"pyproject.toml" , "[tool.pytest.ini_options]\n x=10" , id = "pyproject.toml"
1332
1346
),
1333
1347
pytest .param ("tox.ini" , "[pytest]\n x=10" , id = "tox.ini" ),
1334
- pytest .param ("setup.cfg" , "[tool:pytest]\n x=10" , id = "setup.cfg" ),
1348
+ pytest .param (
1349
+ "setup.cfg" ,
1350
+ "[tool:pytest]\n x=10" ,
1351
+ id = "setup.cfg" ,
1352
+ marks = setup_cfg_nowarn ,
1353
+ ),
1335
1354
],
1336
1355
)
1337
1356
def test_with_ini (self , tmp_path : Path , name : str , contents : str ) -> None :
@@ -1464,6 +1483,7 @@ def test_with_existing_file_in_subdir(
1464
1483
assert rootpath == tmp_path
1465
1484
assert inipath is None
1466
1485
1486
+ @setup_cfg_nowarn
1467
1487
def test_with_config_also_in_parent_directory (
1468
1488
self , tmp_path : Path , monkeypatch : MonkeyPatch
1469
1489
) -> None :
@@ -1481,7 +1501,10 @@ def test_with_config_also_in_parent_directory(
1481
1501
1482
1502
1483
1503
class TestOverrideIniArgs :
1484
- @pytest .mark .parametrize ("name" , "setup.cfg tox.ini pytest.ini" .split ())
1504
+ @pytest .mark .parametrize (
1505
+ "name" ,
1506
+ [pytest .param ("setup.cfg" , marks = setup_cfg_nowarn ), "tox.ini" , "pytest.ini" ],
1507
+ )
1485
1508
def test_override_ini_names (self , pytester : Pytester , name : str ) -> None :
1486
1509
section = "[pytest]" if name != "setup.cfg" else "[tool:pytest]"
1487
1510
pytester .path .joinpath (name ).write_text (
0 commit comments