Skip to content

Commit

Permalink
Extract legacy behavior as a separate function.
Browse files Browse the repository at this point in the history
  • Loading branch information
jaraco committed Jun 22, 2022
1 parent 3b713b7 commit 746a84d
Showing 1 changed file with 12 additions and 6 deletions.
18 changes: 12 additions & 6 deletions pytest_enabler/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,12 +25,18 @@ def none_as_empty(ob):
def read_plugins(filename):
with open(filename) as strm:
defn = toml.load(strm)
if "pytest" in defn and "enabler" in defn["pytest"]:
msg = "pytest-enabler configuration should use the `[tool.pytest-enabler]` "
msg += "table in pyproject.toml (`[pytest.enabler]` is now deprecated)."
warnings.warn(msg, DeprecationWarning)
return defn["pytest"]["enabler"]
return defn["tool"]["pytest-enabler"]
return _read_plugins_legacy(defn) or defn["tool"]["pytest-enabler"]


@suppress(KeyError)
def _read_plugins_legacy(defn):
value = defn["pytest"]["enabler"]
msg = (
"pytest-enabler configuration should use the `[tool.pytest-enabler]` "
"table in pyproject.toml (`[pytest.enabler]` is now deprecated)."
)
warnings.warn(msg, DeprecationWarning)
return value


def pytest_load_initial_conftests(early_config, parser, args):
Expand Down

0 comments on commit 746a84d

Please sign in to comment.