Skip to content

pytest_plugin: 'gitconfig' fixture name collides with pytest-gitconfig #528

@tony

Description

@tony

Summary

libvcs's pytest plugin defines a session-scoped gitconfig fixture that returns a pathlib.Path. The third-party plugin pytest-gitconfig defines a fixture with the same name that returns a GitConfig helper object with a .set() method. When both plugins are installed and auto-loaded, libvcs wins fixture resolution and any downstream test that calls gitconfig.set(...) crashes:

AttributeError: 'PosixPath' object has no attribute 'set'

This was reported downstream against the Arch python-copier package, where the build runs upstream copier's tests with python -m venv --system-site-packages, exposing the system-installed python-libvcs plugin to the test environment: https://aur.archlinux.org/packages/python-copier#comment-1070264

Where the collision lives

  • libvcs registers as the pytest plugin name libvcs via [project.entry-points.pytest11] in pyproject.toml.
  • The colliding fixture is gitconfig in src/libvcs/pytest_plugin.py — session-scoped, returns pathlib.Path.
  • A sibling hgconfig fixture has the same shape and would collide with any equivalent third-party plugin.

The other fixtures in this module already use a vcs_ prefix (vcs_name, vcs_email, vcs_user); gitconfig / hgconfig are the outliers in that module's own naming convention.

Reproduction

$ pip install libvcs pytest-gitconfig
$ cat > test_collision.py <<'PYEOF'
def test_gitconfig_has_set(gitconfig):
    gitconfig.set({"user.name": "x"})
PYEOF
$ pytest test_collision.py
# AttributeError: 'PosixPath' object has no attribute 'set'

$ pytest -p no:libvcs test_collision.py
# passes — pytest-gitconfig's fixture is now visible

Suggested fix

Rename libvcs's gitconfig and hgconfig fixtures to vacate the shared namespace — for example, vcs_gitconfig / vcs_hgconfig, matching the existing vcs_* convention. Internal references (set_gitconfig, git_repo, git_remote_repo, etc.) would be updated at the same time.

If keeping the short names is preferred, a deprecation alias (old name → new name with a DeprecationWarning) would let downstreams migrate without immediate breakage; once the old name is gone, the namespace is free.

I'm happy to send a PR if the rename direction is acceptable.

Workaround for downstream packagers

Until libvcs ships a fix, packagers whose test environment leaks libvcs in (e.g. python -m venv --system-site-packages) can disable just this plugin:

$ pytest -p no:libvcs ...

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions