Skip to content

Consolidate conftest.py to root #440

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 2 commits into from
Sep 20, 2022
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
7 changes: 7 additions & 0 deletions CHANGES
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,13 @@ $ pip install --user --upgrade --pre libtmux
### Tests / docs

- Examples for pytest plugin (#439)
- Move conftest.py to root level (#440)

- https://docs.pytest.org/en/stable/deprecations.html#pytest-plugins-in-non-top-level-conftest-files
- Less conftest.py files
- We can now run py.test for `README.md` without needing to proxy through
`docs/index.md`


## libtmux 0.15.2 (2022-09-17)

Expand Down
46 changes: 46 additions & 0 deletions conftest.py
Original file line number Diff line number Diff line change
@@ -1 +1,47 @@
import pathlib
import shutil
import typing as t

import pytest

from _pytest.doctest import DoctestItem

from libtmux.pytest_plugin import USING_ZSH

if t.TYPE_CHECKING:
from libtmux.session import Session

pytest_plugins = ["pytester"]


@pytest.fixture(autouse=True)
def add_doctest_fixtures(
request: pytest.FixtureRequest,
doctest_namespace: t.Dict[str, t.Any],
) -> None:
if isinstance(request._pyfuncitem, DoctestItem) and shutil.which("tmux"):
request.getfixturevalue("set_home")
doctest_namespace["server"] = request.getfixturevalue("server")
session: "Session" = request.getfixturevalue("session")
doctest_namespace["session"] = session
doctest_namespace["window"] = session.attached_window
doctest_namespace["pane"] = session.attached_pane
doctest_namespace["request"] = request


@pytest.fixture(autouse=True, scope="function")
def set_home(
monkeypatch: pytest.MonkeyPatch,
user_path: pathlib.Path,
) -> None:
monkeypatch.setenv("HOME", str(user_path))


@pytest.fixture(autouse=True, scope="session")
@pytest.mark.usefixtures("clear_env")
def setup(
request: pytest.FixtureRequest,
config_file: pathlib.Path,
) -> None:
if USING_ZSH:
request.getfixturevalue("zshrc")
1 change: 0 additions & 1 deletion docs/conftest.py

This file was deleted.

45 changes: 0 additions & 45 deletions src/libtmux/conftest.py

This file was deleted.

3 changes: 0 additions & 3 deletions tests/conftest.py

This file was deleted.