Skip to content

fix(pytest_plugin): Pytester import, use public APIs from pytest #442

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 6 commits into from
Sep 22, 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
12 changes: 12 additions & 0 deletions CHANGES
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,18 @@ $ pip install --user --upgrade --pre libtmux

- _Insert changes/features/fixes for next release here_

## libtmux 0.15.4 (unreleased)

### Bug fixes

- Use stable `pytest` API imports where possible to fix issues in downstream
packaging on Arch (#441, via #442)

### Packaging

- Add `.tmuxp-before-script.sh` (used by `.tmuxp.yaml`) and `conftest.py` to
source distributoins (#441, via #442)

## libtmux 0.15.3 (2022-09-20)

### Tests / docs
Expand Down
2 changes: 2 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,10 @@ packages = [
include = [
{ path = "CHANGES", format = "sdist" },
{ path = ".tmuxp.yaml", format = "sdist" },
{ path = ".tmuxp-before-script.sh", format = "sdist" },
{ path = "tests", format = "sdist" },
{ path = "docs", format = "sdist" },
{ path = "conftest.py", format = "sdist" },
]

[tool.poetry.urls]
Expand Down
14 changes: 6 additions & 8 deletions tests/test_common.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,6 @@

import pytest

from _pytest.monkeypatch import MonkeyPatch

import libtmux
from libtmux.common import (
TMUX_MAX_VERSION,
Expand All @@ -31,7 +29,7 @@
version_regex = re.compile(r"([0-9]\.[0-9])|(master)")


def test_allows_master_version(monkeypatch: MonkeyPatch) -> None:
def test_allows_master_version(monkeypatch: pytest.MonkeyPatch) -> None:
class Hi:
stdout = ["tmux master"]
stderr = None
Expand All @@ -49,7 +47,7 @@ def mock_tmux_cmd(*args: t.Any, **kwargs: t.Any) -> Hi:
), "Is the latest supported version with -master appended"


def test_allows_next_version(monkeypatch: MonkeyPatch) -> None:
def test_allows_next_version(monkeypatch: pytest.MonkeyPatch) -> None:
TMUX_NEXT_VERSION = str(float(TMUX_MAX_VERSION) + 0.1)

class Hi:
Expand All @@ -67,7 +65,7 @@ def mock_tmux_cmd(*args: t.Any, **kwargs: t.Any) -> Hi:
assert TMUX_NEXT_VERSION == get_version()


def test_get_version_openbsd(monkeypatch: MonkeyPatch) -> None:
def test_get_version_openbsd(monkeypatch: pytest.MonkeyPatch) -> None:
class Hi:
stderr = ["tmux: unknown option -- V"]

Expand All @@ -84,7 +82,7 @@ def mock_tmux_cmd(*args: t.Any, **kwargs: t.Any) -> Hi:
), "Is the latest supported version with -openbsd appended"


def test_get_version_too_low(monkeypatch: MonkeyPatch) -> None:
def test_get_version_too_low(monkeypatch: pytest.MonkeyPatch) -> None:
class Hi:
stderr = ["tmux: unknown option -- V"]

Expand All @@ -97,7 +95,7 @@ def mock_tmux_cmd(*args: t.Any, **kwargs: t.Any) -> Hi:
exc_info.match("is running tmux 1.3 or earlier")


def test_ignores_letter_versions(monkeypatch: MonkeyPatch) -> None:
def test_ignores_letter_versions(monkeypatch: pytest.MonkeyPatch) -> None:
"""Ignore letters such as 1.8b.

See ticket https://github.com/tmux-python/tmuxp/issues/55.
Expand All @@ -120,7 +118,7 @@ def test_ignores_letter_versions(monkeypatch: MonkeyPatch) -> None:
assert type(has_version("1.9a")) is bool


def test_error_version_less_1_7(monkeypatch: MonkeyPatch) -> None:
def test_error_version_less_1_7(monkeypatch: pytest.MonkeyPatch) -> None:
def mock_get_version() -> LooseVersion:
return LooseVersion("1.7")

Expand Down
4 changes: 1 addition & 3 deletions tests/test_pytest_plugin.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,9 @@

import pytest

import _pytest.pytester


def test_plugin(
pytester: _pytest.pytester.Pytester,
pytester: pytest.Pytester,
monkeypatch: pytest.MonkeyPatch,
) -> None:
# Initialize variables
Expand Down