Skip to content

Commit 93dd73a

Browse files
committed
Add few pytest plugins
- improve console output, including displaying error as soon a failure happens - check for git dirty status via pytest-plus
1 parent b2d4620 commit 93dd73a

File tree

4 files changed

+15
-5
lines changed

4 files changed

+15
-5
lines changed

.config/constraints.txt

+6-3
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ mkdocstrings-python==1.13.0 # via mkdocs-ansible
6666
mypy==1.14.1 # via ansible-creator (pyproject.toml)
6767
mypy-extensions==1.0.0 # via black, mypy
6868
nodeenv==1.9.1 # via pre-commit
69-
packaging==24.2 # via ansible-compat, ansible-core, ansible-lint, black, mkdocs, mkdocs-macros-plugin, pyproject-api, pytest, tox
69+
packaging==24.2 # via ansible-compat, ansible-core, ansible-lint, black, mkdocs, mkdocs-macros-plugin, pyproject-api, pytest, pytest-sugar, tox
7070
paginate==0.5.7 # via mkdocs-material
7171
pathspec==0.12.1 # via ansible-lint, black, mkdocs, mkdocs-macros-plugin, yamllint
7272
pillow==11.1.0 # via cairosvg, mkdocs-ansible
@@ -79,7 +79,10 @@ pygments==2.19.1 # via mkdocs-material
7979
pylint==3.3.4 # via ansible-creator (pyproject.toml)
8080
pymdown-extensions==10.14.3 # via markdown-exec, mkdocs-ansible, mkdocs-material, mkdocstrings
8181
pyproject-api==1.9.0 # via tox
82-
pytest==8.3.4 # via pytest-xdist, ansible-creator (pyproject.toml)
82+
pytest==8.3.4 # via pytest-instafail, pytest-plus, pytest-sugar, pytest-xdist, ansible-creator (pyproject.toml)
83+
pytest-instafail==0.5.0 # via ansible-creator (pyproject.toml)
84+
pytest-plus==0.8.1 # via ansible-creator (pyproject.toml)
85+
pytest-sugar==1.0.0 # via ansible-creator (pyproject.toml)
8386
pytest-xdist==3.6.1 # via ansible-creator (pyproject.toml)
8487
python-dateutil==2.9.0.post0 # via ghp-import, mkdocs-macros-plugin
8588
python-slugify==8.0.4 # via mkdocs-monorepo-plugin
@@ -95,7 +98,7 @@ six==1.17.0 # via python-dateutil
9598
soupsieve==2.6 # via beautifulsoup4
9699
subprocess-tee==0.4.2 # via ansible-compat, ansible-lint
97100
super-collections==0.5.3 # via mkdocs-macros-plugin
98-
termcolor==2.5.0 # via mkdocs-macros-plugin
101+
termcolor==2.5.0 # via mkdocs-macros-plugin, pytest-sugar
99102
text-unidecode==1.3 # via python-slugify
100103
tinycss2==1.4.0 # via cairosvg, cssselect2
101104
toml-sort==0.24.2 # via ansible-creator (pyproject.toml)

.config/requirements-test.in

+3
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,9 @@ pre-commit
66
pydoclint
77
pylint
88
pytest
9+
pytest-instafail
10+
pytest-plus
11+
pytest-sugar
912
pytest-xdist
1013
ruff
1114
toml-sort

tests/units/test_init.py

+5-1
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,9 @@
2020
from tests.defaults import FIXTURES_DIR, UUID_LENGTH
2121

2222

23+
dircmp_ignore = [".DS_Store", ".ansible"]
24+
25+
2326
class ConfigDict(TypedDict):
2427
"""Type hint for Config dictionary.
2528
@@ -129,7 +132,7 @@ def mock_unique_name_in_devfile(init: Init) -> str:
129132
assert re.search(r"Note: collection project created", result) is not None
130133

131134
# recursively assert files created
132-
cmp = dircmp(str(tmp_path), str(FIXTURES_DIR / "collection"), ignore=[".DS_Store"])
135+
cmp = dircmp(str(tmp_path), str(FIXTURES_DIR / "collection"), ignore=dircmp_ignore)
133136
diff = has_differences(dcmp=cmp, errors=[])
134137
assert diff == [], diff
135138

@@ -215,6 +218,7 @@ def mock_unique_name_in_devfile(init: Init) -> str:
215218
cmp = dircmp(
216219
str(tmp_path / "new_project"),
217220
str(FIXTURES_DIR / "project" / "playbook_project"),
221+
ignore=dircmp_ignore,
218222
)
219223
diff = has_differences(dcmp=cmp, errors=[])
220224
assert diff == [], diff

tests/units/test_output.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ def test_console_width(width: int, expected: int, monkeypatch: pytest.MonkeyPatc
2323
"""Test the console width function."""
2424

2525
def mock_get_terminal_size() -> SimpleNamespace:
26-
return SimpleNamespace(columns=width, lines=24)
26+
return SimpleNamespace(columns=width, lines=24, fallback=(width, 24))
2727

2828
monkeypatch.setattr("shutil.get_terminal_size", mock_get_terminal_size)
2929

0 commit comments

Comments
 (0)