Skip to content

Commit faa771a

Browse files
committed
Rename t decorator to server, test_server to py.test funcs
1 parent 781129b commit faa771a

File tree

2 files changed

+52
-49
lines changed

2 files changed

+52
-49
lines changed

tests/conftest.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,15 +12,16 @@
1212

1313

1414
@pytest.fixture(scope='session')
15-
def t():
15+
def server():
1616
t = Server()
1717
t.socket_name = 'tmuxp_test'
1818

1919
return t
2020

2121

2222
@pytest.fixture(scope='function')
23-
def session(t):
23+
def session(server):
24+
t = server
2425
session_name = 'tmuxp'
2526
if not t.has_session(session_name):
2627
t.cmd('new-session', '-d', '-s', session_name)

tests/test_server.py

Lines changed: 49 additions & 47 deletions
Original file line numberDiff line numberDiff line change
@@ -7,75 +7,77 @@
77
import logging
88

99
from tmuxp import Server
10-
from .helpers import TmuxTestCase
1110

1211
logger = logging.getLogger(__name__)
1312

1413

15-
class ServerTest(TmuxTestCase):
14+
def test_has_session(server, session):
15+
assert server.has_session(session.get('session_name'))
16+
assert not server.has_session('asdf2314324321')
1617

17-
def test_has_session(self):
18-
assert self.t.has_session(self.TEST_SESSION_NAME)
19-
assert not self.t.has_session('asdf2314324321')
2018

21-
def test_socket_name(self):
22-
""" ``-L`` socket_name.
19+
def test_socket_name():
20+
""" ``-L`` socket_name.
2321
24-
``-L`` socket_name file name of socket. which will be stored in
25-
env TMUX_TMPDIR or /tmp if unset.)
22+
``-L`` socket_name file name of socket. which will be stored in
23+
env TMUX_TMPDIR or /tmp if unset.)
2624
27-
"""
28-
myserver = Server(socket_name='test')
25+
"""
26+
myserver = Server(socket_name='test')
2927

30-
assert myserver.socket_name == 'test'
28+
assert myserver.socket_name == 'test'
3129

32-
def test_socket_path(self):
33-
""" ``-S`` socket_path (alternative path for server socket). """
34-
myserver = Server(socket_path='test')
3530

36-
assert myserver.socket_path == 'test'
31+
def test_socket_path():
32+
""" ``-S`` socket_path (alternative path for server socket). """
33+
myserver = Server(socket_path='test')
3734

38-
def test_config(self):
39-
""" ``-f`` file for tmux(1) configuration. """
40-
myserver = Server(config_file='test')
41-
assert myserver.config_file == 'test'
35+
assert myserver.socket_path == 'test'
4236

43-
def test_256_colors(self):
44-
myserver = Server(colors=256)
45-
assert myserver.colors == 256
4637

47-
proc = myserver.cmd('list-servers')
38+
def test_config():
39+
""" ``-f`` file for tmux(1) configuration. """
40+
myserver = Server(config_file='test')
41+
assert myserver.config_file == 'test'
4842

49-
assert '-2' in proc.cmd
50-
assert '-8' not in proc.cmd
5143

52-
def test_88_colors(self):
53-
myserver = Server(colors=88)
54-
assert myserver.colors == 88
44+
def test_256_colors():
45+
myserver = Server(colors=256)
46+
assert myserver.colors == 256
5547

56-
proc = myserver.cmd('list-servers')
48+
proc = myserver.cmd('list-servers')
5749

58-
assert '-8' in proc.cmd
59-
assert '-2' not in proc.cmd
50+
assert '-2' in proc.cmd
51+
assert '-8' not in proc.cmd
6052

6153

62-
class EnvironmentTest(TmuxTestCase):
54+
def test_88_colors():
55+
myserver = Server(colors=88)
56+
assert myserver.colors == 88
6357

64-
def test_show_environment(self):
65-
"""Server.show_environment() returns dict."""
66-
vars = self.server.show_environment()
67-
assert isinstance(vars, dict)
58+
proc = myserver.cmd('list-servers')
6859

69-
def test_set_show_environment_single(self):
70-
"""Set environment then Server.show_environment(key)."""
71-
self.server.set_environment('FOO', 'BAR')
72-
assert 'BAR' == self.server.show_environment('FOO')
60+
assert '-8' in proc.cmd
61+
assert '-2' not in proc.cmd
7362

74-
self.server.set_environment('FOO', 'DAR')
75-
assert 'DAR' == self.server.show_environment('FOO')
7663

77-
assert 'DAR' == self.server.show_environment()['FOO']
64+
def test_show_environment(server):
65+
"""Server.show_environment() returns dict."""
66+
_vars = server.show_environment()
67+
assert isinstance(_vars, dict)
7868

79-
def test_show_environment_not_set(self):
80-
"""Unset environment variable returns None."""
81-
assert self.server.show_environment('BAR') is None
69+
70+
def test_set_show_environment_single(server):
71+
"""Set environment then Server.show_environment(key)."""
72+
server.set_environment('FOO', 'BAR')
73+
assert 'BAR' == server.show_environment('FOO')
74+
75+
server.set_environment('FOO', 'DAR')
76+
assert 'DAR' == server.show_environment('FOO')
77+
78+
assert 'DAR' == server.show_environment()['FOO']
79+
80+
81+
def test_show_environment_not_set(server):
82+
"""Unset environment variable returns None."""
83+
assert server.show_environment('BAR') is None

0 commit comments

Comments
 (0)