Skip to content

Commit

Permalink
Revert pytest-dev#3523 - instead of deprecating we will drop the docs
Browse files Browse the repository at this point in the history
  • Loading branch information
RonnyPfannschmidt committed Jun 6, 2021
1 parent 015fcf4 commit 3a0ffa5
Show file tree
Hide file tree
Showing 4 changed files with 4 additions and 41 deletions.
7 changes: 0 additions & 7 deletions src/_pytest/config/findpaths.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import os
import warnings
from pathlib import Path
from typing import Dict
from typing import Iterable
Expand All @@ -11,7 +10,6 @@
from typing import Union

from .exceptions import UsageError
from _pytest.deprecated import SETUP_CFG_CONFIG
from _pytest.outcomes import fail
from _pytest.pathlib import absolutepath
from _pytest.pathlib import commonpath
Expand Down Expand Up @@ -71,11 +69,6 @@ def _parse_cfg_file(path: Path) -> PARSE_RESULT:
iniconfig = _parse_ini_config(path)

if "tool:pytest" in iniconfig.sections:

if path.name == "setup.cfg":
warnings.warn_explicit(
SETUP_CFG_CONFIG, None, os.fspath(path), 0, module="pytest"
)
return dict(iniconfig["tool:pytest"].items())
elif "pytest" in iniconfig.sections:
# If a setup.cfg contains a "[pytest]" section, we raise a failure to indicate users that
Expand Down
6 changes: 0 additions & 6 deletions src/_pytest/deprecated.py
Original file line number Diff line number Diff line change
Expand Up @@ -88,12 +88,6 @@
" (options: {names})",
)

SETUP_CFG_CONFIG = PytestDeprecationWarning(
"configuring pytest in setup.cfg has been deprecated \n"
"as pytest and setuptools do not share he same config parser\n"
"please consider pytest.ini/tox.ini or pyproject.toml"
)


NODE_FSPATH = UnformattedWarning(
PytestDeprecationWarning,
Expand Down
31 changes: 4 additions & 27 deletions testing/test_config.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,18 +31,9 @@
from _pytest.pytester import Pytester


setup_cfg_nowarn = pytest.mark.filterwarnings(
"ignore:.*setup.cfg.*:pytest.PytestDeprecationWarning"
)


class TestParseIni:
@pytest.mark.parametrize(
"section, filename",
[
("pytest", "pytest.ini"),
pytest.param("tool:pytest", "setup.cfg", marks=setup_cfg_nowarn),
],
"section, filename", [("pytest", "pytest.ini"), ("tool:pytest", "setup.cfg")]
)
def test_getcfg_and_config(
self,
Expand Down Expand Up @@ -71,7 +62,6 @@ def test_getcfg_and_config(
config = pytester.parseconfigure(str(sub))
assert config.inicfg["name"] == "value"

@setup_cfg_nowarn
def test_setupcfg_uses_toolpytest_with_pytest(self, pytester: Pytester) -> None:
p1 = pytester.makepyfile("def test(): pass")
pytester.makefile(
Expand Down Expand Up @@ -122,11 +112,7 @@ def test_tox_ini_wrong_version(self, pytester: Pytester) -> None:

@pytest.mark.parametrize(
"section, name",
[
pytest.param("tool:pytest", "setup.cfg", marks=setup_cfg_nowarn),
("pytest", "tox.ini"),
("pytest", "pytest.ini"),
],
[("tool:pytest", "setup.cfg"), ("pytest", "tox.ini"), ("pytest", "pytest.ini")],
)
def test_ini_names(self, pytester: Pytester, name, section) -> None:
pytester.path.joinpath(name).write_text(
Expand Down Expand Up @@ -1345,12 +1331,7 @@ def test_simple_noini(self, tmp_path: Path, monkeypatch: MonkeyPatch) -> None:
"pyproject.toml", "[tool.pytest.ini_options]\nx=10", id="pyproject.toml"
),
pytest.param("tox.ini", "[pytest]\nx=10", id="tox.ini"),
pytest.param(
"setup.cfg",
"[tool:pytest]\nx=10",
id="setup.cfg",
marks=setup_cfg_nowarn,
),
pytest.param("setup.cfg", "[tool:pytest]\nx=10", id="setup.cfg"),
],
)
def test_with_ini(self, tmp_path: Path, name: str, contents: str) -> None:
Expand Down Expand Up @@ -1483,7 +1464,6 @@ def test_with_existing_file_in_subdir(
assert rootpath == tmp_path
assert inipath is None

@setup_cfg_nowarn
def test_with_config_also_in_parent_directory(
self, tmp_path: Path, monkeypatch: MonkeyPatch
) -> None:
Expand All @@ -1501,10 +1481,7 @@ def test_with_config_also_in_parent_directory(


class TestOverrideIniArgs:
@pytest.mark.parametrize(
"name",
[pytest.param("setup.cfg", marks=setup_cfg_nowarn), "tox.ini", "pytest.ini"],
)
@pytest.mark.parametrize("name", "setup.cfg tox.ini pytest.ini".split())
def test_override_ini_names(self, pytester: Pytester, name: str) -> None:
section = "[pytest]" if name != "setup.cfg" else "[tool:pytest]"
pytester.path.joinpath(name).write_text(
Expand Down
1 change: 0 additions & 1 deletion testing/test_mark.py
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,6 @@ def test_markers():
rec.assertoutcome(passed=1)


@pytest.mark.filterwarnings("ignore:.*setup.cfg.*:pytest.PytestDeprecationWarning")
def test_marker_without_description(pytester: Pytester) -> None:
pytester.makefile(
".cfg",
Expand Down

0 comments on commit 3a0ffa5

Please sign in to comment.