Skip to content

Commit 01d3ba5

Browse files
committed
chore(tests[legacy_common]): pydocstyle manual fixes
1 parent d8b56b1 commit 01d3ba5

File tree

1 file changed

+35
-11
lines changed

1 file changed

+35
-11
lines changed

tests/legacy_api/test_common.py

Lines changed: 35 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,7 @@
11
"""Tests for utility functions in libtmux."""
2-
32
import re
43
import sys
54
import typing as t
6-
from typing import Optional
75

86
import pytest
97

@@ -30,6 +28,8 @@
3028

3129

3230
def test_allows_master_version(monkeypatch: pytest.MonkeyPatch) -> None:
31+
"""Assert get_version() works with builds from git trunk."""
32+
3333
class Hi:
3434
stdout: t.ClassVar = ["tmux master"]
3535
stderr = None
@@ -48,6 +48,7 @@ def mock_tmux_cmd(*args: t.Any, **kwargs: t.Any) -> Hi:
4848

4949

5050
def test_allows_next_version(monkeypatch: pytest.MonkeyPatch) -> None:
51+
"""Assert get_version() supports next version."""
5152
TMUX_NEXT_VERSION = str(float(TMUX_MAX_VERSION) + 0.1)
5253

5354
class Hi:
@@ -66,6 +67,8 @@ def mock_tmux_cmd(*args: t.Any, **kwargs: t.Any) -> Hi:
6667

6768

6869
def test_get_version_openbsd(monkeypatch: pytest.MonkeyPatch) -> None:
70+
"""Assert get_version() with OpenBSD versions."""
71+
6972
class Hi:
7073
stderr: t.ClassVar = ["tmux: unknown option -- V"]
7174

@@ -83,6 +86,8 @@ def mock_tmux_cmd(*args: t.Any, **kwargs: t.Any) -> Hi:
8386

8487

8588
def test_get_version_too_low(monkeypatch: pytest.MonkeyPatch) -> None:
89+
"""Assert get_version() raises if tmux version too low."""
90+
8691
class Hi:
8792
stderr: t.ClassVar = ["tmux: unknown option -- V"]
8893

@@ -96,7 +101,7 @@ def mock_tmux_cmd(*args: t.Any, **kwargs: t.Any) -> Hi:
96101

97102

98103
def test_ignores_letter_versions(monkeypatch: pytest.MonkeyPatch) -> None:
99-
"""Ignore letters such as 1.8b.
104+
"""Tests version utilities ignores letters such as 1.8b.
100105
101106
See ticket https://github.com/tmux-python/tmuxp/issues/55.
102107
@@ -119,6 +124,8 @@ def test_ignores_letter_versions(monkeypatch: pytest.MonkeyPatch) -> None:
119124

120125

121126
def test_error_version_less_1_7(monkeypatch: pytest.MonkeyPatch) -> None:
127+
"""Test raises if tmux version less than 1.7."""
128+
122129
def mock_get_version() -> LooseVersion:
123130
return LooseVersion("1.7")
124131

@@ -134,10 +141,12 @@ def mock_get_version() -> LooseVersion:
134141

135142

136143
def test_has_version() -> None:
144+
"""Test has_version()."""
137145
assert has_version(str(get_version()))
138146

139147

140148
def test_has_gt_version() -> None:
149+
"""Test has_gt_version()."""
141150
assert has_gt_version("1.6")
142151
assert has_gt_version("1.6b")
143152

@@ -146,6 +155,7 @@ def test_has_gt_version() -> None:
146155

147156

148157
def test_has_gte_version() -> None:
158+
"""Test has_gte_version()."""
149159
assert has_gte_version("1.6")
150160
assert has_gte_version("1.6b")
151161
assert has_gte_version(str(get_version()))
@@ -155,6 +165,7 @@ def test_has_gte_version() -> None:
155165

156166

157167
def test_has_lt_version() -> None:
168+
"""Test has_lt_version()."""
158169
assert has_lt_version("4.0a")
159170
assert has_lt_version("4.0")
160171

@@ -163,6 +174,7 @@ def test_has_lt_version() -> None:
163174

164175

165176
def test_has_lte_version() -> None:
177+
"""Test has_lti_version()."""
166178
assert has_lte_version("4.0a")
167179
assert has_lte_version("4.0")
168180
assert has_lte_version(str(get_version()))
@@ -172,29 +184,40 @@ def test_has_lte_version() -> None:
172184

173185

174186
def test_tmux_cmd_raises_on_not_found(monkeypatch: pytest.MonkeyPatch) -> None:
187+
"""Verify raises if tmux command not found."""
175188
monkeypatch.setenv("PATH", "")
176189
with pytest.raises(TmuxCommandNotFound):
177190
tmux_cmd("-V")
178191

179192

180193
def test_tmux_cmd_unicode(session: Session) -> None:
194+
"""Verify tmux commands with unicode."""
181195
session.cmd("new-window", "-t", 3, "-n", "юникод", "-F", "Ελληνικά")
182196

183197

198+
class SessionCheckName(t.NamedTuple):
199+
"""Test fixture for test_session_check_name()."""
200+
201+
session_name: t.Optional[str]
202+
raises: bool
203+
exc_msg_regex: t.Optional[str]
204+
205+
184206
@pytest.mark.parametrize(
185-
"session_name,raises,exc_msg_regex",
207+
SessionCheckName._fields,
186208
[
187-
("", True, "empty"),
188-
(None, True, "empty"),
189-
("my great session.", True, "contains periods"),
190-
("name: great session", True, "contains colons"),
191-
("new great session", False, None),
192-
("ajf8a3fa83fads,,,a", False, None),
209+
SessionCheckName("", True, "empty"),
210+
SessionCheckName(None, True, "empty"),
211+
SessionCheckName("my great session.", True, "contains periods"),
212+
SessionCheckName("name: great session", True, "contains colons"),
213+
SessionCheckName("new great session", False, None),
214+
SessionCheckName("ajf8a3fa83fads,,,a", False, None),
193215
],
194216
)
195217
def test_session_check_name(
196-
session_name: Optional[str], raises: bool, exc_msg_regex: Optional[str]
218+
session_name: t.Optional[str], raises: bool, exc_msg_regex: t.Optional[str]
197219
) -> None:
220+
"""Verify session_check_name()."""
198221
if raises:
199222
with pytest.raises(BadSessionName) as exc_info:
200223
session_check_name(session_name)
@@ -205,6 +228,7 @@ def test_session_check_name(
205228

206229

207230
def test_get_libtmux_version() -> None:
231+
"""Verify get_libtmux_version()."""
208232
from libtmux.__about__ import __version__
209233

210234
version = get_libtmux_version()

0 commit comments

Comments
 (0)