Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Minor test improvements #4234

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
43 changes: 22 additions & 21 deletions .config/constraints.txt
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,10 @@
#
# pip-compile --all-extras --no-annotate --output-file=.config/constraints.txt --strip-extras .config/requirements.in pyproject.toml
#
ansi2html==1.9.1
ansi2html==1.9.2
ansible-compat==24.6.1
ansible-core==2.17.0
ansible-lint==24.6.0
ansible-core==2.17.1
ansible-lint==24.6.1
astroid==3.2.2
attrs==23.2.0
babel==2.15.0
Expand All @@ -16,37 +16,38 @@ black==24.4.2
bracex==2.4
build==1.2.1
cachetools==5.3.3
cairocffi==1.7.0
cairocffi==1.7.1
cairosvg==2.7.1
certifi==2024.6.2
cffi==1.16.0
cfgv==3.4.0
chardet==5.2.0
charset-normalizer==3.3.2
check-jsonschema==0.28.5
check-jsonschema==0.28.6
click==8.1.7
click-help-colors==0.9.4
colorama==0.4.6
coverage==7.5.3
coverage==7.5.4
cryptography==42.0.8
csscompressor==0.9.5
cssselect2==0.7.0
defusedxml==0.7.1
dill==0.3.8
distlib==0.3.8
dnspython==2.6.1
docstring-parser-fork==0.0.5
docker==7.1.0
docstring-parser-fork==0.0.8
enrich==1.2.7
exceptiongroup==1.2.1
execnet==2.1.1
filelock==3.15.1
filelock==3.15.4
flake8==7.1.0
ghp-import==2.1.0
griffe==0.45.3
griffe==0.47.0
htmlmin2==0.1.13
identify==2.5.36
idna==3.7
importlib-metadata==7.1.0
importlib-metadata==7.2.1
iniconfig==2.0.0
isort==5.13.2
jinja2==3.1.4
Expand All @@ -55,7 +56,7 @@ jsonschema==4.22.0
jsonschema-specifications==2023.12.1
linkchecker==10.4.0
markdown==3.6
markdown-exec==1.9.1
markdown-exec==1.9.3
markdown-include==0.8.1
markdown-it-py==3.0.0
markupsafe==2.1.5
Expand All @@ -69,13 +70,13 @@ mkdocs-gen-files==0.5.0
mkdocs-get-deps==0.2.0
mkdocs-htmlproofer-plugin==1.2.1
mkdocs-macros-plugin==1.0.5
mkdocs-material==9.5.26
mkdocs-material==9.5.27
mkdocs-material-extensions==1.3.1
mkdocs-minify-plugin==0.8.0
mkdocs-monorepo-plugin==1.1.0
mkdocstrings==0.25.1
mkdocstrings-python==1.10.3
mypy==1.10.0
mkdocstrings-python==1.10.5
mypy==1.10.1
mypy-extensions==1.0.0
nodeenv==1.9.1
packaging==24.1
Expand All @@ -84,19 +85,19 @@ pathspec==0.12.1
pexpect==4.9.0
pillow==10.3.0
pip-tools==7.4.1
pipdeptree==2.22.0
pipdeptree==2.23.0
platformdirs==4.2.2
pluggy==1.5.0
pre-commit==3.7.1
ptyprocess==0.7.0
pycodestyle==2.12.0
pycparser==2.22
pydoclint==0.4.1
pydoclint==0.5.1
pyflakes==3.2.0
pygments==2.18.0
pylint==3.2.3
pymdown-extensions==10.8.1
pyproject-api==1.6.1
pyproject-api==1.7.1
pyproject-hooks==1.1.0
pytest==8.2.2
pytest-mock==3.14.0
Expand All @@ -116,10 +117,10 @@ rich==13.7.1
rpds-py==0.18.1
ruamel-yaml==0.18.6
ruamel-yaml-clib==0.2.8
ruff==0.4.9
ruff==0.4.10
six==1.16.0
soupsieve==2.5
subprocess-tee==0.4.1
subprocess-tee==0.4.2
termcolor==2.4.0
text-unidecode==1.3
tinycss2==1.3.0
Expand All @@ -131,8 +132,8 @@ types-jsonschema==4.22.0.20240610
types-pexpect==4.9.0.20240311
types-pyyaml==6.0.12.20240311
typing-extensions==4.12.2
urllib3==2.2.1
virtualenv==20.26.2
urllib3==2.2.2
virtualenv==20.26.3
watchdog==4.0.1
wcmatch==8.5.2
webencodings==0.5.1
Expand Down
2 changes: 2 additions & 0 deletions .config/pydoclint-baseline.txt
Original file line number Diff line number Diff line change
Expand Up @@ -703,6 +703,8 @@ src/molecule/verifier/testinfra.py
DOC203: Method `Testinfra._get_tests` return type(s) in docstring not consistent with the return annotation. Return annotation has 0 type(s); docstring return section has 1 type(s).
--------------------
tests/conftest.py
DOC101: Function `_no_color`: Docstring contains fewer arguments than in function signature.
DOC103: Function `_no_color`: Docstring arguments are different from function arguments. (Or could be other formatting issues: https://jsh9.github.io/pydoclint/violation_codes.html#notes-on-doc103 ). Arguments in the function signature but not in the docstring: [monkeypatch: pytest.MonkeyPatch].
DOC101: Function `reset_pytest_vars`: Docstring contains fewer arguments than in function signature.
DOC106: Function `reset_pytest_vars`: The option `--arg-type-hints-in-signature` is `True` but there are no argument type hints in the signature
DOC107: Function `reset_pytest_vars`: The option `--arg-type-hints-in-signature` is `True` but not all args in the signature have type hints
Expand Down
1 change: 1 addition & 0 deletions .config/requirements-test.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ ansible-lint >= 6.12.1
black
check-jsonschema
coverage[toml]
docker >= 7.1.0 # testing
filelock >= 3.9.0
flake8
mypy
Expand Down
2 changes: 1 addition & 1 deletion .config/requirements.in
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
ansible-compat >= 24.6.1
ansible-core >= 2.12.10
ansible-core >= 2.15.0
click >= 8.0, < 9
click-help-colors
enrich >= 1.2.7
Expand Down
3 changes: 2 additions & 1 deletion .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@ ci:
autoupdate_commit_msg: "chore: pre-commit autoupdate"
autoupdate_schedule: monthly
autofix_commit_msg: "chore: auto fixes from pre-commit.com hooks"
default_language_version:
python: python3.10 # minimal we support officially for consistent results

repos:
- repo: https://github.com/pre-commit/pre-commit-hooks
Expand Down Expand Up @@ -130,7 +132,6 @@ repos:
--strip-extras
--output-file=.config/constraints.txt pyproject.toml
files: ^.config\/.*requirements.*$
language_version: "3.10" # minimal we support officially
- repo: https://github.com/ansible/ansible-lint
rev: v24.6.1
hooks:
Expand Down
2 changes: 1 addition & 1 deletion collections/requirements.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,6 @@
collections:
- name: community.crypto
- name: community.docker
version: ">=3.10.2"
version: ">=3.10.4"
- name: containers.podman
- name: kubernetes.core
4 changes: 4 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,7 @@ module = [
[tool.pydoclint]
arg-type-hints-in-docstring = false
baseline = ".config/pydoclint-baseline.txt"
exclude = '\.git|\.test_logs|\.tox|build|out|venv'
show-filenames-in-every-violation-message = true
skip-checking-short-docstrings = false
style = "google"
Expand Down Expand Up @@ -345,6 +346,9 @@ verbosity_assertions = 2
[tool.ruff]
builtins = ["__"]
cache-dir = "./.cache/.ruff"
external = [
"DOC" # pydoclint
]
fix = true
line-length = 100
target-version = "py310"
Expand Down
11 changes: 11 additions & 0 deletions tests/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,17 @@ def is_subset(subset, superset): # type: ignore[no-untyped-def] # noqa: ANN001
return subset == superset


@pytest.fixture(autouse=True)
def _no_color(monkeypatch: pytest.MonkeyPatch) -> None:
"""Disable coloring output."""
# Analyzing output with no color is much easier. Tests that need to test for
# color output, should override the value.
monkeypatch.setitem(os.environ, "NO_COLOR", "1")
monkeypatch.delitem(os.environ, "PY_COLORS", raising=False)
monkeypatch.delitem(os.environ, "ANSIBLE_FORCE_COLOR", raising=False)
monkeypatch.delitem(os.environ, "FORCE_COLOR", raising=False)


@pytest.fixture()
def resources_folder_path() -> Path:
"""Return the path to the resources folder.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
collections:
- name: community.docker
version: ">=3.10.2"
version: ">=3.10.4"
3 changes: 2 additions & 1 deletion tests/integration/test_command.py
Original file line number Diff line number Diff line change
Expand Up @@ -340,4 +340,5 @@ def test_smoke(monkeypatch: pytest.MonkeyPatch, test_fixture_dir: Path) -> None:
"""
monkeypatch.chdir(test_fixture_dir)
command = ["molecule", "test", "--scenario-name", "smoke"]
assert run_command(command).returncode == 0
result = run_command(command)
assert result.returncode == 0, result
1 change: 1 addition & 0 deletions tests/unit/test_logger.py
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,7 @@ def test_markup_detection_pycolors0(monkeypatch): # type: ignore[no-untyped-def


def test_markup_detection_pycolors1(monkeypatch): # type: ignore[no-untyped-def] # noqa: ANN001, ANN201, D103
monkeypatch.delenv("NO_COLOR", raising=False)
monkeypatch.setenv("PY_COLORS", "1")
assert should_do_markup()

Expand Down
Loading