1
1
"""Tests for utility functions in libtmux."""
2
-
3
2
import re
4
3
import sys
5
4
import typing as t
29
28
30
29
31
30
def test_allows_master_version (monkeypatch : pytest .MonkeyPatch ) -> None :
31
+ """Assert get_version() works with builds from git trunk."""
32
+
32
33
class Hi :
33
34
stdout : t .ClassVar = ["tmux master" ]
34
35
stderr = None
@@ -47,6 +48,7 @@ def mock_tmux_cmd(*args: t.Any, **kwargs: t.Any) -> Hi:
47
48
48
49
49
50
def test_allows_next_version (monkeypatch : pytest .MonkeyPatch ) -> None :
51
+ """Assert get_version() supports next version."""
50
52
TMUX_NEXT_VERSION = str (float (TMUX_MAX_VERSION ) + 0.1 )
51
53
52
54
class Hi :
@@ -65,6 +67,8 @@ def mock_tmux_cmd(*args: t.Any, **kwargs: t.Any) -> Hi:
65
67
66
68
67
69
def test_get_version_openbsd (monkeypatch : pytest .MonkeyPatch ) -> None :
70
+ """Assert get_version() with OpenBSD versions."""
71
+
68
72
class Hi :
69
73
stderr : t .ClassVar = ["tmux: unknown option -- V" ]
70
74
@@ -82,6 +86,8 @@ def mock_tmux_cmd(*args: t.Any, **kwargs: t.Any) -> Hi:
82
86
83
87
84
88
def test_get_version_too_low (monkeypatch : pytest .MonkeyPatch ) -> None :
89
+ """Assert get_version() raises if tmux version too low."""
90
+
85
91
class Hi :
86
92
stderr : t .ClassVar = ["tmux: unknown option -- V" ]
87
93
@@ -95,7 +101,7 @@ def mock_tmux_cmd(*args: t.Any, **kwargs: t.Any) -> Hi:
95
101
96
102
97
103
def test_ignores_letter_versions (monkeypatch : pytest .MonkeyPatch ) -> None :
98
- """Ignore letters such as 1.8b.
104
+ """Tests version utilities ignores letters such as 1.8b.
99
105
100
106
See ticket https://github.com/tmux-python/tmuxp/issues/55.
101
107
@@ -118,6 +124,8 @@ def test_ignores_letter_versions(monkeypatch: pytest.MonkeyPatch) -> None:
118
124
119
125
120
126
def test_error_version_less_1_7 (monkeypatch : pytest .MonkeyPatch ) -> None :
127
+ """Test raises if tmux version less than 1.7."""
128
+
121
129
def mock_get_version () -> LooseVersion :
122
130
return LooseVersion ("1.7" )
123
131
@@ -133,10 +141,12 @@ def mock_get_version() -> LooseVersion:
133
141
134
142
135
143
def test_has_version () -> None :
144
+ """Test has_version()."""
136
145
assert has_version (str (get_version ()))
137
146
138
147
139
148
def test_has_gt_version () -> None :
149
+ """Test has_gt_version()."""
140
150
assert has_gt_version ("1.6" )
141
151
assert has_gt_version ("1.6b" )
142
152
@@ -145,6 +155,7 @@ def test_has_gt_version() -> None:
145
155
146
156
147
157
def test_has_gte_version () -> None :
158
+ """Test has_gte_version()."""
148
159
assert has_gte_version ("1.6" )
149
160
assert has_gte_version ("1.6b" )
150
161
assert has_gte_version (str (get_version ()))
@@ -154,6 +165,7 @@ def test_has_gte_version() -> None:
154
165
155
166
156
167
def test_has_lt_version () -> None :
168
+ """Test has_lt_version()."""
157
169
assert has_lt_version ("4.0a" )
158
170
assert has_lt_version ("4.0" )
159
171
@@ -162,6 +174,7 @@ def test_has_lt_version() -> None:
162
174
163
175
164
176
def test_has_lte_version () -> None :
177
+ """Test has_lti_version()."""
165
178
assert has_lte_version ("4.0a" )
166
179
assert has_lte_version ("4.0" )
167
180
assert has_lte_version (str (get_version ()))
@@ -171,16 +184,20 @@ def test_has_lte_version() -> None:
171
184
172
185
173
186
def test_tmux_cmd_raises_on_not_found (monkeypatch : pytest .MonkeyPatch ) -> None :
187
+ """Verify raises if tmux command not found."""
174
188
monkeypatch .setenv ("PATH" , "" )
175
189
with pytest .raises (TmuxCommandNotFound ):
176
190
tmux_cmd ("-V" )
177
191
178
192
179
193
def test_tmux_cmd_unicode (session : Session ) -> None :
194
+ """Verify tmux commands with unicode."""
180
195
session .cmd ("new-window" , "-t" , 3 , "-n" , "юникод" , "-F" , "Ελληνικά" )
181
196
182
197
183
198
class SessionCheckName (t .NamedTuple ):
199
+ """Test fixture for test_session_check_name()."""
200
+
184
201
session_name : t .Optional [str ]
185
202
raises : bool
186
203
exc_msg_regex : t .Optional [str ]
@@ -200,6 +217,7 @@ class SessionCheckName(t.NamedTuple):
200
217
def test_session_check_name (
201
218
session_name : t .Optional [str ], raises : bool , exc_msg_regex : t .Optional [str ]
202
219
) -> None :
220
+ """Verify session_check_name()."""
203
221
if raises :
204
222
with pytest .raises (BadSessionName ) as exc_info :
205
223
session_check_name (session_name )
@@ -210,6 +228,7 @@ def test_session_check_name(
210
228
211
229
212
230
def test_get_libtmux_version () -> None :
231
+ """Verify get_libtmux_version()."""
213
232
from libtmux .__about__ import __version__
214
233
215
234
version = get_libtmux_version ()
0 commit comments