|
6 | 6 |
|
7 | 7 | import logging |
8 | 8 | import os |
9 | | -import re |
10 | 9 |
|
11 | 10 | import pytest |
12 | 11 |
|
13 | | -from libtmux.common import has_required_tmux_version |
14 | | -from libtmux.exc import LibTmuxException |
15 | 12 | from tmuxp import exc |
16 | 13 | from tmuxp.exc import BeforeLoadScriptError, BeforeLoadScriptNotExists |
17 | 14 | from tmuxp.util import run_before_script |
|
20 | 17 |
|
21 | 18 | logger = logging.getLogger(__name__) |
22 | 19 |
|
23 | | -version_regex = re.compile(r'[0-9]\.[0-9]') |
24 | | - |
25 | | - |
26 | | -def test_no_arg_uses_tmux_version(): |
27 | | - """Test the :meth:`has_required_tmux_version`.""" |
28 | | - result = has_required_tmux_version() |
29 | | - assert version_regex.match(result) is not None |
30 | | - |
31 | | - |
32 | | -def test_ignores_letter_versions(): |
33 | | - """Ignore letters such as 1.8b. |
34 | | -
|
35 | | - See ticket https://github.com/tony/tmuxp/issues/55. |
36 | | -
|
37 | | - In version 0.1.7 this is adjusted to use LooseVersion, in order to |
38 | | - allow letters. |
39 | | -
|
40 | | - """ |
41 | | - result = has_required_tmux_version('1.9a') |
42 | | - assert version_regex.match(result) is not None |
43 | | - |
44 | | - result = has_required_tmux_version('1.8a') |
45 | | - assert result == r'1.8' |
46 | | - |
47 | | - |
48 | | -def test_error_version_less_1_7(): |
49 | | - with pytest.raises(LibTmuxException) as excinfo: |
50 | | - has_required_tmux_version('1.7') |
51 | | - excinfo.match(r'tmuxp only supports') |
52 | | - |
53 | | - with pytest.raises(LibTmuxException) as excinfo: |
54 | | - has_required_tmux_version('1.6a') |
55 | | - |
56 | | - excinfo.match(r'tmuxp only supports') |
57 | | - |
58 | | - has_required_tmux_version('1.9a') |
59 | | - |
60 | 20 |
|
61 | 21 | def test_raise_BeforeLoadScriptNotExists_if_not_exists(): |
62 | 22 | script_file = os.path.join(fixtures_dir, 'script_noexists.sh') |
|
0 commit comments