#3268 Added deprecation to custom configs
This commit is contained in:
parent
ea854086e1
commit
99aab2c3f5
|
@ -1329,10 +1329,14 @@ def determine_setup(inifile, args, warnfunc=None, rootdir_cmd_arg=None):
|
||||||
if inifile:
|
if inifile:
|
||||||
iniconfig = py.iniconfig.IniConfig(inifile)
|
iniconfig = py.iniconfig.IniConfig(inifile)
|
||||||
is_cfg_file = str(inifile).endswith('.cfg')
|
is_cfg_file = str(inifile).endswith('.cfg')
|
||||||
|
# TODO: [pytest] section in *.cfg files is depricated. Need refactoring.
|
||||||
sections = ['tool:pytest', 'pytest'] if is_cfg_file else ['pytest']
|
sections = ['tool:pytest', 'pytest'] if is_cfg_file else ['pytest']
|
||||||
for section in sections:
|
for section in sections:
|
||||||
try:
|
try:
|
||||||
inicfg = iniconfig[section]
|
inicfg = iniconfig[section]
|
||||||
|
if is_cfg_file and section == 'pytest' and warnfunc:
|
||||||
|
from _pytest.deprecated import SETUP_CFG_PYTEST
|
||||||
|
warnfunc('C1', SETUP_CFG_PYTEST.replace('setup.cfg', str(inifile)))
|
||||||
break
|
break
|
||||||
except KeyError:
|
except KeyError:
|
||||||
inicfg = None
|
inicfg = None
|
||||||
|
|
|
@ -48,6 +48,15 @@ def test_pytest_setup_cfg_deprecated(testdir):
|
||||||
result.stdout.fnmatch_lines(['*pytest*section in setup.cfg files is deprecated*use*tool:pytest*instead*'])
|
result.stdout.fnmatch_lines(['*pytest*section in setup.cfg files is deprecated*use*tool:pytest*instead*'])
|
||||||
|
|
||||||
|
|
||||||
|
def test_pytest_custom_cfg_deprecated(testdir):
|
||||||
|
testdir.makefile('.cfg', custom='''
|
||||||
|
[pytest]
|
||||||
|
addopts = --verbose
|
||||||
|
''')
|
||||||
|
result = testdir.runpytest("-c", "custom.cfg")
|
||||||
|
result.stdout.fnmatch_lines(['*pytest*section in custom.cfg files is deprecated*use*tool:pytest*instead*'])
|
||||||
|
|
||||||
|
|
||||||
def test_str_args_deprecated(tmpdir, testdir):
|
def test_str_args_deprecated(tmpdir, testdir):
|
||||||
"""Deprecate passing strings to pytest.main(). Scheduled for removal in pytest-4.0."""
|
"""Deprecate passing strings to pytest.main(). Scheduled for removal in pytest-4.0."""
|
||||||
from _pytest.main import EXIT_NOTESTSCOLLECTED
|
from _pytest.main import EXIT_NOTESTSCOLLECTED
|
||||||
|
|
Loading…
Reference in New Issue