Skip to content

Fix test failure with pyenv or mise pythons #275

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

Merged
merged 1 commit into from
Dec 17, 2024
Merged
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
4 changes: 4 additions & 0 deletions .config/pydoclint-baseline.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
tests/unit/test_treemaker.py
DOC101: Method `SafeEnvBuilder.__init__`: Docstring contains fewer arguments than in function signature.
DOC103: Method `SafeEnvBuilder.__init__`: 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: [clear: bool, prompt: str | None, symlinks: bool, system_site_packages: bool, upgrade: bool, upgrade_deps: bool, with_pip: bool].
--------------------
3 changes: 2 additions & 1 deletion .github/workflows/tox.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,10 @@ jobs:
uses: ansible/team-devtools/.github/workflows/tox.yml@main
with:
max_python: "3.13"
jobs_producing_coverage: 7
jobs_producing_coverage: 8
other_names: |
docs
lint
pkg
py313-milestone
py-mise:tox -e py:mise=true
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -169,3 +169,4 @@ cython_debug/
/src/*/_version.py

.DS_Store
_readthedocs/
16 changes: 4 additions & 12 deletions .readthedocs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,20 +6,12 @@ mkdocs:
configuration: mkdocs.yml

build:
os: ubuntu-22.04
os: ubuntu-24.04
tools:
python: "3.11"
python: "3.13"
commands:
- pip install --user tox
- python3 -m tox -e docs -- --strict --site-dir=_readthedocs/html/
python:
install:
- method: pip
path: tox
- method: pip
path: .
extra_requirements:
- docs
- python3 -m pip install --user tox
- python3 -m tox -e docs
submodules:
include: all
recursive: true
2 changes: 2 additions & 0 deletions .tool-versions
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
# mise: 'latest' for python might pick 3.13.0t which is not yet supported
python 3.13.0
38 changes: 33 additions & 5 deletions tests/unit/test_treemaker.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,33 @@
from ansible_dev_environment.utils import JSONVal


class SafeEnvBuilder(EnvBuilder):
"""Safer EnvBuilder that defaults symlinks to True."""

# pylint: disable=too-many-arguments
def __init__( # noqa: PLR0913
self,
*,
system_site_packages: bool = False,
clear: bool = False,
symlinks: bool = True,
upgrade: bool = False,
with_pip: bool = False,
prompt: str | None = None,
upgrade_deps: bool = False,
) -> None:
"""Ensure that symlinks defaults to True because otherwise it will create broken venvs with tools like pyenv, asdf or mise."""
super().__init__(
system_site_packages=system_site_packages,
clear=clear,
symlinks=symlinks,
upgrade=upgrade,
with_pip=with_pip,
prompt=prompt,
upgrade_deps=upgrade_deps,
)


def test_tree_empty(
capsys: pytest.CaptureFixture[str],
output: Output,
Expand All @@ -32,7 +59,8 @@ def test_tree_empty(
tmp_path: Pytest fixture.
"""
venv_path = tmp_path / "venv"
EnvBuilder().create(venv_path)
env = SafeEnvBuilder()
env.create(venv_path)

args = Namespace(
venv=venv_path,
Expand Down Expand Up @@ -63,7 +91,7 @@ def test_tree_malformed_info(
tmp_path: Pytest fixture.
"""
venv_path = tmp_path / "venv"
EnvBuilder().create(venv_path)
SafeEnvBuilder().create(venv_path)

args = Namespace(
venv=venv_path,
Expand Down Expand Up @@ -118,7 +146,7 @@ def test_tree_malformed_deps(
tmp_path: Pytest fixture.
"""
venv_path = tmp_path / "venv"
EnvBuilder().create(venv_path)
SafeEnvBuilder().create(venv_path)

args = Namespace(
venv=venv_path,
Expand Down Expand Up @@ -175,7 +203,7 @@ def test_tree_malformed_deps_not_string(
tmp_path: Pytest fixture.
"""
venv_path = tmp_path / "venv"
EnvBuilder().create(venv_path)
SafeEnvBuilder().create(venv_path)

args = Namespace(
venv=venv_path,
Expand Down Expand Up @@ -232,7 +260,7 @@ def test_tree_malformed_repo_not_string(
capsys: Pytest stdout capture fixture.
"""
venv_path = tmp_path / "venv"
EnvBuilder().create(venv_path)
SafeEnvBuilder().create(venv_path)

args = Namespace(
venv=venv_path,
Expand Down
4 changes: 2 additions & 2 deletions tox.ini
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ allowlist_externals =

[testenv:deps]
description = Bump all dependencies
base_python = python3.10
base_python = python3.11
skip_install = true
deps =
{[testenv:lint]deps}
Expand All @@ -75,7 +75,7 @@ set_env =
NO_COLOR = 1
TERM = dump
commands =
mkdocs build {posargs:}
mkdocs build --strict --site-dir=_readthedocs/html/ {posargs:}

[testenv:lint]
description = Enforce quality standards under {basepython}
Expand Down
Loading