Move setup.cfg error message and tests to an appropriate location
Those are not really deprecated anymore and are part of the normal code for config
This commit is contained in:
parent
647d89c444
commit
f2b7809d5d
|
@ -20,8 +20,6 @@ def getcfg(args, config=None):
|
||||||
|
|
||||||
note: config is optional and used only to issue warnings explicitly (#2891).
|
note: config is optional and used only to issue warnings explicitly (#2891).
|
||||||
"""
|
"""
|
||||||
from _pytest.deprecated import CFG_PYTEST_SECTION
|
|
||||||
|
|
||||||
inibasenames = ["pytest.ini", "tox.ini", "setup.cfg"]
|
inibasenames = ["pytest.ini", "tox.ini", "setup.cfg"]
|
||||||
args = [x for x in args if not str(x).startswith("-")]
|
args = [x for x in args if not str(x).startswith("-")]
|
||||||
if not args:
|
if not args:
|
||||||
|
@ -97,6 +95,9 @@ def get_dirs_from_args(args):
|
||||||
return [get_dir_from_path(path) for path in possible_paths if path.exists()]
|
return [get_dir_from_path(path) for path in possible_paths if path.exists()]
|
||||||
|
|
||||||
|
|
||||||
|
CFG_PYTEST_SECTION = "[pytest] section in {filename} files is no longer supported, change to [tool:pytest] instead."
|
||||||
|
|
||||||
|
|
||||||
def determine_setup(inifile, args, rootdir_cmd_arg=None, config=None):
|
def determine_setup(inifile, args, rootdir_cmd_arg=None, config=None):
|
||||||
dirs = get_dirs_from_args(args)
|
dirs = get_dirs_from_args(args)
|
||||||
if inifile:
|
if inifile:
|
||||||
|
@ -107,8 +108,6 @@ def determine_setup(inifile, args, rootdir_cmd_arg=None, config=None):
|
||||||
try:
|
try:
|
||||||
inicfg = iniconfig[section]
|
inicfg = iniconfig[section]
|
||||||
if is_cfg_file and section == "pytest" and config is not None:
|
if is_cfg_file and section == "pytest" and config is not None:
|
||||||
from _pytest.deprecated import CFG_PYTEST_SECTION
|
|
||||||
|
|
||||||
fail(
|
fail(
|
||||||
CFG_PYTEST_SECTION.format(filename=str(inifile)), pytrace=False
|
CFG_PYTEST_SECTION.format(filename=str(inifile)), pytrace=False
|
||||||
)
|
)
|
||||||
|
|
|
@ -33,8 +33,6 @@ FIXTURE_NAMED_REQUEST = PytestDeprecationWarning(
|
||||||
"'request' is a reserved name for fixtures and will raise an error in future versions"
|
"'request' is a reserved name for fixtures and will raise an error in future versions"
|
||||||
)
|
)
|
||||||
|
|
||||||
CFG_PYTEST_SECTION = "[pytest] section in {filename} files is no longer supported, change to [tool:pytest] instead."
|
|
||||||
|
|
||||||
|
|
||||||
FUNCARGNAMES = PytestDeprecationWarning(
|
FUNCARGNAMES = PytestDeprecationWarning(
|
||||||
"The `funcargnames` attribute was an alias for `fixturenames`, "
|
"The `funcargnames` attribute was an alias for `fixturenames`, "
|
||||||
|
|
|
@ -4,30 +4,6 @@ from _pytest import deprecated
|
||||||
pytestmark = pytest.mark.pytester_example_path("deprecated")
|
pytestmark = pytest.mark.pytester_example_path("deprecated")
|
||||||
|
|
||||||
|
|
||||||
def test_pytest_setup_cfg_unsupported(testdir):
|
|
||||||
testdir.makefile(
|
|
||||||
".cfg",
|
|
||||||
setup="""
|
|
||||||
[pytest]
|
|
||||||
addopts = --verbose
|
|
||||||
""",
|
|
||||||
)
|
|
||||||
with pytest.raises(pytest.fail.Exception):
|
|
||||||
testdir.runpytest()
|
|
||||||
|
|
||||||
|
|
||||||
def test_pytest_custom_cfg_unsupported(testdir):
|
|
||||||
testdir.makefile(
|
|
||||||
".cfg",
|
|
||||||
custom="""
|
|
||||||
[pytest]
|
|
||||||
addopts = --verbose
|
|
||||||
""",
|
|
||||||
)
|
|
||||||
with pytest.raises(pytest.fail.Exception):
|
|
||||||
testdir.runpytest("-c", "custom.cfg")
|
|
||||||
|
|
||||||
|
|
||||||
@pytest.mark.filterwarnings("default")
|
@pytest.mark.filterwarnings("default")
|
||||||
def test_resultlog_is_deprecated(testdir):
|
def test_resultlog_is_deprecated(testdir):
|
||||||
result = testdir.runpytest("--help")
|
result = testdir.runpytest("--help")
|
||||||
|
|
|
@ -1245,6 +1245,30 @@ def test_config_blocked_default_plugins(testdir, plugin):
|
||||||
assert result.stdout.lines == [""]
|
assert result.stdout.lines == [""]
|
||||||
|
|
||||||
|
|
||||||
|
class TestSetupCfg:
|
||||||
|
def test_pytest_setup_cfg_unsupported(self, testdir):
|
||||||
|
testdir.makefile(
|
||||||
|
".cfg",
|
||||||
|
setup="""
|
||||||
|
[pytest]
|
||||||
|
addopts = --verbose
|
||||||
|
""",
|
||||||
|
)
|
||||||
|
with pytest.raises(pytest.fail.Exception):
|
||||||
|
testdir.runpytest()
|
||||||
|
|
||||||
|
def test_pytest_custom_cfg_unsupported(self, testdir):
|
||||||
|
testdir.makefile(
|
||||||
|
".cfg",
|
||||||
|
custom="""
|
||||||
|
[pytest]
|
||||||
|
addopts = --verbose
|
||||||
|
""",
|
||||||
|
)
|
||||||
|
with pytest.raises(pytest.fail.Exception):
|
||||||
|
testdir.runpytest("-c", "custom.cfg")
|
||||||
|
|
||||||
|
|
||||||
class TestPytestPluginsVariable:
|
class TestPytestPluginsVariable:
|
||||||
def test_pytest_plugins_in_non_top_level_conftest_unsupported(self, testdir):
|
def test_pytest_plugins_in_non_top_level_conftest_unsupported(self, testdir):
|
||||||
testdir.makepyfile(
|
testdir.makepyfile(
|
||||||
|
|
Loading…
Reference in New Issue