Skip to content

Commit ca35a7a

Browse files
committed
fix: fail fast if testinfra plugin is detected
To avoid confusing error messages, fail fast if testinfra plugin is detected. - #509 - pytest-dev/pytest-testinfra#58
1 parent 4540fcb commit ca35a7a

File tree

2 files changed

+9
-0
lines changed

2 files changed

+9
-0
lines changed

.config/dictionary.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,7 @@ pytrace
5050
reportinfo
5151
runpytest
5252
superfences
53+
testinfra
5354
testpaths
5455
webservers
5556
xunit

src/pytest_ansible/plugin.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
from __future__ import annotations
44

5+
import importlib.util
56
import logging
67
import shutil
78
import subprocess # noqa: S404
@@ -103,9 +104,16 @@ def pytest_addoption(parser: pytest.Parser) -> None:
103104
104105
Args:
105106
parser: pytest.Parser
107+
108+
Raises:
109+
pytest.UsageError: If pytest-testinfra is installed.
106110
"""
107111
if not HAS_ANSIBLE:
108112
return
113+
spec = importlib.util.find_spec("testinfra")
114+
if spec is not None:
115+
msg = "pytest-ansible is incompatible with pytest-testinfra, see https://github.com/ansible/pytest-ansible/issues/509"
116+
raise pytest.UsageError(msg)
109117
group = parser.getgroup("pytest-ansible")
110118
group.addoption(
111119
"--inventory",

0 commit comments

Comments
 (0)