Skip to content

Commit ef58b0a

Browse files
committed
fix tmux git master test, consolidate mock classes
1 parent ad7f4f6 commit ef58b0a

File tree

1 file changed

+10
-11
lines changed

1 file changed

+10
-11
lines changed

tests/test_common.py

Lines changed: 10 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -21,20 +21,21 @@
2121

2222

2323
def test_allows_master_version(monkeypatch):
24-
def mock_get_version():
25-
return LooseVersion('master')
26-
monkeypatch.setattr(libtmux.common, 'get_version', mock_get_version)
24+
def mock_tmux_cmd(param):
25+
class Hi(object):
26+
stdout = ['tmux master']
27+
stderr = None
28+
return Hi()
29+
monkeypatch.setattr(libtmux.common, 'tmux_cmd', mock_tmux_cmd)
2730

2831
assert has_minimum_version()
2932

3033

3134
def test_get_version_openbsd(monkeypatch):
3235
def mock_tmux_cmd(param):
3336
class Hi(object):
34-
pass
35-
proc = Hi()
36-
proc.stderr = ['tmux: unknown option -- V']
37-
return proc
37+
stderr = ['tmux: unknown option -- V']
38+
return Hi()
3839
monkeypatch.setattr(libtmux.common, 'tmux_cmd', mock_tmux_cmd)
3940
monkeypatch.setattr(sys, 'platform', 'openbsd 5.2')
4041
assert get_version() == LooseVersion(TMUX_MAX_VERSION)
@@ -43,10 +44,8 @@ class Hi(object):
4344
def test_get_version_too_low(monkeypatch):
4445
def mock_tmux_cmd(param):
4546
class Hi(object):
46-
pass
47-
proc = Hi()
48-
proc.stderr = ['tmux: unknown option -- V']
49-
return proc
47+
stderr = ['tmux: unknown option -- V']
48+
return Hi()
5049
monkeypatch.setattr(libtmux.common, 'tmux_cmd', mock_tmux_cmd)
5150
with pytest.raises(LibTmuxException) as exc_info:
5251
get_version()

0 commit comments

Comments
 (0)