Skip to content
Closed
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
1 change: 1 addition & 0 deletions .github/workflows/ci-cd.yml
Original file line number Diff line number Diff line change
Expand Up @@ -596,6 +596,7 @@ jobs:
fail_ci_if_error: >-
${{ fromJSON(needs.pre-setup.outputs.is-upstream-repository) }}
run_command: send-notifications
token: ${{ secrets.CODECOV_TOKEN }}

publish-pypi:
name: >-
Expand Down
3 changes: 3 additions & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -291,6 +291,9 @@ repos:
additional_dependencies:
- covdefaults # needed by pylint-pytest due to pytest-cov loading coverage
- pylint-pytest ~= 2.0.0a0
# pylint-pytest crashes on pytest 9.2:
# https://github.com/pylint-dev/pylint-pytest/issues/163
- pytest < 9.2
- pytest-cov # needed by pylint-pytest since it picks up pytest's args
- pytest-xdist # needed by pylint-pytest since it picks up pytest's args
- pytest-subtests
Expand Down
3 changes: 3 additions & 0 deletions pytest.ini
Original file line number Diff line number Diff line change
Expand Up @@ -77,4 +77,7 @@ norecursedirs =

testpaths = tests/

usefixtures =
_isolate_user_environment

xfail_strict = true
7 changes: 1 addition & 6 deletions src/tox_plugins/pre_commit/_plugin.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@
if _t.TYPE_CHECKING:
from collections import abc as _c # noqa: WPS347

from tox.config.sets import ConfigSet
from tox.session.state import State


Expand All @@ -37,13 +36,9 @@ def tox_extend_envs() -> _c.Iterable[str]:


@impl
def tox_add_core_config(
core_conf: ConfigSet, # ruff: ignore[unused-function-argument] # pylint: disable=unused-argument
state: State,
) -> None:
def tox_add_core_config(state: State) -> None:
"""Inject default configuration for the pre-commit environment.

:param core_conf: The core tox configuration set (unused).
:param state: The tox session state to inject environments into.
"""
pos_args = state.conf.pos_args(to_path=None)
Expand Down
17 changes: 13 additions & 4 deletions tests/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,17 +3,26 @@
from __future__ import annotations

import os
import typing as _t

import pytest


if _t.TYPE_CHECKING:
from collections import abc as _c # noqa: WPS347


pytest_plugins = ('tox.pytest',)


@pytest.fixture(autouse=True)
def _isolate_user_environment(monkeypatch: pytest.MonkeyPatch) -> None:
@pytest.fixture
def _isolate_user_environment() -> _c.Iterator[None]:
"""Isolate the tests from the user's tox configuration.

:param monkeypatch: Pytest's environment-manipulation fixture.
:yields: Control to the test while the user configuration is hidden.
"""
monkeypatch.setenv('TOX_USER_CONFIG_FILE', os.devnull)
# `usefixtures` starts this before tox's environment check, so its own
# monkeypatch must outlive that check rather than share the test's one
with pytest.MonkeyPatch.context() as monkeypatch:
monkeypatch.setenv('TOX_USER_CONFIG_FILE', os.devnull)
yield
Loading