|
2 | 2 | """Test for tmuxp plugin api."""
|
3 | 3 | from __future__ import absolute_import
|
4 | 4 |
|
| 5 | +import pytest |
| 6 | + |
5 | 7 | from tmuxp.exc import TmuxpPluginException
|
6 | 8 |
|
7 | 9 | from .fixtures.pluginsystem.partials.all_pass import AllVersionPassPlugin
|
8 |
| -from .fixtures.pluginsystem.partials.tmux_version_fail import ( |
9 |
| - TmuxVersionFailMinPlugin, |
10 |
| - TmuxVersionFailMaxPlugin, |
11 |
| - TmuxVersionFailIncompatiblePlugin, |
12 |
| -) |
13 | 10 | from .fixtures.pluginsystem.partials.libtmux_version_fail import (
|
14 |
| - LibtmuxVersionFailMinPlugin, |
15 |
| - LibtmuxVersionFailMaxPlugin, |
16 | 11 | LibtmuxVersionFailIncompatiblePlugin,
|
| 12 | + LibtmuxVersionFailMaxPlugin, |
| 13 | + LibtmuxVersionFailMinPlugin, |
| 14 | +) |
| 15 | +from .fixtures.pluginsystem.partials.tmux_version_fail import ( |
| 16 | + TmuxVersionFailIncompatiblePlugin, |
| 17 | + TmuxVersionFailMaxPlugin, |
| 18 | + TmuxVersionFailMinPlugin, |
17 | 19 | )
|
18 | 20 | from .fixtures.pluginsystem.partials.tmuxp_version_fail import (
|
19 |
| - TmuxpVersionFailMinPlugin, |
20 |
| - TmuxpVersionFailMaxPlugin, |
21 | 21 | TmuxpVersionFailIncompatiblePlugin,
|
| 22 | + TmuxpVersionFailMaxPlugin, |
| 23 | + TmuxpVersionFailMinPlugin, |
22 | 24 | )
|
23 | 25 |
|
24 | 26 |
|
25 | 27 | def test_all_pass():
|
26 |
| - try: |
27 |
| - AllVersionPassPlugin() |
28 |
| - assert True |
29 |
| - except TmuxpPluginException: |
30 |
| - assert False |
| 28 | + AllVersionPassPlugin() |
31 | 29 |
|
32 | 30 |
|
33 | 31 | def test_tmux_version_fail_min():
|
34 |
| - try: |
| 32 | + with pytest.raises(TmuxpPluginException, match=r'Incompatible.*') as exc_info: |
35 | 33 | TmuxVersionFailMinPlugin()
|
36 |
| - assert False |
37 |
| - except TmuxpPluginException as error: |
38 |
| - assert 'Incompatible' in error.__str__() |
| 34 | + assert 'tmux-min-version-fail' in str(exc_info.value) |
39 | 35 |
|
40 | 36 |
|
41 | 37 | def test_tmux_version_fail_max():
|
42 |
| - try: |
| 38 | + with pytest.raises(TmuxpPluginException, match=r'Incompatible.*') as exc_info: |
43 | 39 | TmuxVersionFailMaxPlugin()
|
44 |
| - assert False |
45 |
| - except TmuxpPluginException as error: |
46 |
| - assert 'Incompatible' in error.__str__() |
| 40 | + assert 'tmux-max-version-fail' in str(exc_info.value) |
47 | 41 |
|
48 | 42 |
|
49 | 43 | def test_tmux_version_fail_incompatible():
|
50 |
| - try: |
| 44 | + with pytest.raises(TmuxpPluginException, match=r'Incompatible.*') as exc_info: |
51 | 45 | TmuxVersionFailIncompatiblePlugin()
|
52 |
| - assert False |
53 |
| - except TmuxpPluginException as error: |
54 |
| - assert 'Incompatible' in error.__str__() |
| 46 | + assert 'tmux-incompatible-version-fail' in str(exc_info.value) |
55 | 47 |
|
56 | 48 |
|
57 | 49 | def test_tmuxp_version_fail_min():
|
58 |
| - try: |
| 50 | + with pytest.raises(TmuxpPluginException, match=r'Incompatible.*') as exc_info: |
59 | 51 | TmuxpVersionFailMinPlugin()
|
60 |
| - assert False |
61 |
| - except TmuxpPluginException as error: |
62 |
| - assert 'Incompatible' in error.__str__() |
| 52 | + assert 'tmuxp-min-version-fail' in str(exc_info.value) |
63 | 53 |
|
64 | 54 |
|
65 | 55 | def test_tmuxp_version_fail_max():
|
66 |
| - try: |
| 56 | + with pytest.raises(TmuxpPluginException, match=r'Incompatible.*') as exc_info: |
67 | 57 | TmuxpVersionFailMaxPlugin()
|
68 |
| - assert False |
69 |
| - except TmuxpPluginException as error: |
70 |
| - assert 'Incompatible' in error.__str__() |
| 58 | + assert 'tmuxp-max-version-fail' in str(exc_info.value) |
71 | 59 |
|
72 | 60 |
|
73 | 61 | def test_tmuxp_version_fail_incompatible():
|
74 |
| - try: |
| 62 | + with pytest.raises(TmuxpPluginException, match=r'Incompatible.*') as exc_info: |
75 | 63 | TmuxpVersionFailIncompatiblePlugin()
|
76 |
| - assert False |
77 |
| - except TmuxpPluginException as error: |
78 |
| - assert 'Incompatible' in error.__str__() |
| 64 | + assert 'tmuxp-incompatible-version-fail' in str(exc_info.value) |
79 | 65 |
|
80 | 66 |
|
81 | 67 | def test_libtmux_version_fail_min():
|
82 |
| - try: |
| 68 | + with pytest.raises(TmuxpPluginException, match=r'Incompatible.*') as exc_info: |
83 | 69 | LibtmuxVersionFailMinPlugin()
|
84 |
| - assert False |
85 |
| - except TmuxpPluginException as error: |
86 |
| - assert 'Incompatible' in error.__str__() |
| 70 | + assert 'libtmux-min-version-fail' in str(exc_info.value) |
87 | 71 |
|
88 | 72 |
|
89 | 73 | def test_libtmux_version_fail_max():
|
90 |
| - try: |
| 74 | + with pytest.raises(TmuxpPluginException, match=r'Incompatible.*') as exc_info: |
91 | 75 | LibtmuxVersionFailMaxPlugin()
|
92 |
| - assert False |
93 |
| - except TmuxpPluginException as error: |
94 |
| - assert 'Incompatible' in error.__str__() |
| 76 | + assert 'libtmux-max-version-fail' in str(exc_info.value) |
95 | 77 |
|
96 | 78 |
|
97 | 79 | def test_libtmux_version_fail_incompatible():
|
98 |
| - try: |
| 80 | + with pytest.raises(TmuxpPluginException, match=r'Incompatible.*') as exc_info: |
99 | 81 | LibtmuxVersionFailIncompatiblePlugin()
|
100 |
| - assert False |
101 |
| - except TmuxpPluginException as error: |
102 |
| - assert 'Incompatible' in error.__str__() |
| 82 | + assert 'libtmux-incompatible-version-fail' in str(exc_info.value) |
0 commit comments