Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Switch to py.test #151

Merged
merged 47 commits into from
May 22, 2016
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
47 commits
Select commit Hold shift + click to select a range
4a587df
Ignore all types of virtualenv dir
tony May 21, 2016
ace8043
Refactor tests structure for py.test, optimize helper imports
tony May 21, 2016
553ac81
Ignore .cache/ and .eggs/
tony May 21, 2016
dfa1cb1
switch window rename to use sh shell as test
tony May 21, 2016
8c18356
Add flaky for rerunning those tricky testcases
tony May 21, 2016
bd6616a
reorder test deps
tony May 21, 2016
82ed172
Update pip, wheel, virtualenv before install on travis
tony May 21, 2016
79b981b
Try upgrading setuptools
tony May 21, 2016
06779a1
Upgrade pytest
tony May 21, 2016
20b3fd1
try upgrading setuptools/pip once more
tony May 21, 2016
9bfd122
Omit tests/ dir from coveragerc
tony May 21, 2016
8f380b6
remove run-tests.py
tony May 21, 2016
a06bc09
Update make test command to py.test
tony May 21, 2016
2c467b3
Clean up old TestLoader infrastructure
tony May 21, 2016
03df8df
flake8 for tests also
tony May 21, 2016
bd7e8f9
Refactor tests for py.test fixture, polish
tony May 21, 2016
d416a53
Update docs for new test directions
tony May 21, 2016
bebbd88
Update README/dox/MANIFEST.in to rm run-tests.py and use make test
tony May 21, 2016
120106c
switch to py.test style asserts, cleanup param order
tony May 21, 2016
713a5e8
port cli tests to py.test functions
tony May 21, 2016
43b4973
midway commit of py.test function rewrite test_config
tony May 22, 2016
e5abc75
Move second expansion test to yaml files+fixtures
tony May 22, 2016
2823379
add util to load fixtures, more tests to fixtures, py.test functions
tony May 22, 2016
41e89ed
move sample config to fixture
tony May 22, 2016
9314c5c
helper function to make loading configs brief
tony May 22, 2016
d9b1de0
Finish test_config py.test fixturization/function conversion
tony May 22, 2016
fcd54c3
Briefen fixture name
tony May 22, 2016
8cbeac7
Move load fixtures to tests/fixtures root
tony May 22, 2016
3141d81
teamocil config tests to fixtures
tony May 22, 2016
e788ab5
Move rest of tmuxinator configs to fixtures
tony May 22, 2016
9f8adcb
move tests for test helpers to tests/tests/
tony May 22, 2016
4316aa0
convert window test to functional, add server/session test fixtures
tony May 22, 2016
10b8eb8
parametrize multisession teamocil import test
tony May 22, 2016
795df2e
Move rest of teamocil config tests to py.test
tony May 22, 2016
781129b
tmuxinator tests to py.test parametrized funcs
tony May 22, 2016
faa771a
Rename t decorator to server, test_server to py.test funcs
tony May 22, 2016
66a9493
move test_session to py.test funcs
tony May 22, 2016
b9eb738
port test_tmuxobject to py.test
tony May 22, 2016
f877bae
workspace{builder,freeze} split fixtures, tweak flaky
tony May 22, 2016
7df1b3c
move more tests (util, workspacebuilder) to py.test func
tony May 22, 2016
8225be1
convert rest tests to py.test
tony May 22, 2016
e7b0591
Clean out unused test helpers, fixture usage fixes
tony May 22, 2016
310ebcc
remove unittest2 dep
tony May 22, 2016
586456b
Fix indentation in setup.py
tony May 22, 2016
447f917
fixes to test decorators, run in function scope for now
tony May 22, 2016
91ccb36
rm unittest2 dep from tox
tony May 22, 2016
2fab3a0
Update doc for pytest
tony May 22, 2016
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
convert window test to functional, add server/session test fixtures
  • Loading branch information
tony committed May 22, 2016
commit 4316aa08a4acffcf49e329fe0403691b2e083ff7
62 changes: 62 additions & 0 deletions tests/conftest.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,67 @@
# -*- coding: utf-8 -*-

import pytest

import logging
from tmuxp import exc
from tmuxp.server import Server

from .helpers import get_test_session_name, TEST_SESSION_PREFIX

logger = logging.getLogger(__name__)


@pytest.fixture(scope='session')
def t():
t = Server()
t.socket_name = 'tmuxp_test'

return t


@pytest.fixture(scope='function')
def session(t):
session_name = 'tmuxp'
if not t.has_session(session_name):
t.cmd('new-session', '-d', '-s', session_name)

# find current sessions prefixed with tmuxp
old_test_sessions = [
s.get('session_name') for s in t._sessions
if s.get('session_name').startswith(TEST_SESSION_PREFIX)
]

TEST_SESSION_NAME = get_test_session_name(server=t)

try:
session = t.new_session(
session_name=TEST_SESSION_NAME,
)
except exc.TmuxpException as e:
raise e

"""
Make sure that tmuxp can :ref:`test_builder_visually` and switches to
the newly created session for that testcase.
"""
try:
t.switch_client(session.get('session_id'))
pass
except exc.TmuxpException as e:
# t.attach_session(session.get('session_id'))
pass

for old_test_session in old_test_sessions:
logger.debug(
'Old test test session %s found. Killing it.' %
old_test_session
)
t.kill_session(old_test_session)
assert TEST_SESSION_NAME == session.get('session_name')
assert TEST_SESSION_NAME != 'tmuxp'

return session


@pytest.fixture()
def tmpdir(tmpdir_factory):
Expand Down
3 changes: 0 additions & 3 deletions tests/helpers.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,6 @@
import tempfile
from contextlib import contextmanager

import pytest

from tmuxp import exc
from tmuxp.server import Server

Expand Down Expand Up @@ -148,7 +146,6 @@ class TmuxTestCase(TestCase):
def temp_session(self, session_name=None):
return temp_session(self.server, session_name)

@pytest.fixture(autouse=True)
def setUp(self):
"""Run bootstrap if :attr:`~.session` is not set."""

Expand Down
64 changes: 31 additions & 33 deletions tests/test_pane.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,50 +6,48 @@

import logging

from .helpers import TmuxTestCase

logger = logging.getLogger(__name__)


class ResizeTest(TmuxTestCase):
def test_resize_pane(session):
""" Test Pane.resize_pane(). """

window = session.attached_window()
window.rename_window('test_resize_pane')

def test_resize_pane(self):
""" Test Pane.resize_pane(). """
pane1 = window.attached_pane()
pane1_height = pane1['pane_height']
window.split_window()

window = self.session.attached_window()
window.rename_window('test_resize_pane')
pane1.resize_pane(height=4)
assert pane1['pane_height'] != pane1_height
assert int(pane1['pane_height']) == 4

pane1 = window.attached_pane()
pane1_height = pane1['pane_height']
window.split_window()
pane1.resize_pane(height=3)
assert int(pane1['pane_height']) == 3

pane1.resize_pane(height=4)
assert pane1['pane_height'] != pane1_height
assert int(pane1['pane_height']) == 4

pane1.resize_pane(height=3)
assert int(pane1['pane_height']) == 3
def test_set_height(session):
window = session.new_window(window_name='test_set_height')
window.split_window()
pane1 = window.attached_pane()
pane1_height = pane1['pane_height']

def test_set_height(self):
window = self.session.new_window(window_name='test_set_height')
window.split_window()
pane1 = window.attached_pane()
pane1_height = pane1['pane_height']
pane1.set_height(2)
assert pane1['pane_height'] != pane1_height
assert int(pane1['pane_height']) == 2

pane1.set_height(2)
assert pane1['pane_height'] != pane1_height
assert int(pane1['pane_height']) == 2

def test_set_width(self):
window = self.session.new_window(window_name='test_set_width')
window.split_window()
def test_set_width(session):
window = session.new_window(window_name='test_set_width')
window.split_window()

window.select_layout('main-vertical')
pane1 = window.attached_pane()
pane1_width = pane1['pane_width']
window.select_layout('main-vertical')
pane1 = window.attached_pane()
pane1_width = pane1['pane_width']

pane1.set_width(10)
assert pane1['pane_width'] != pane1_width
assert int(pane1['pane_width']) == 10
pane1.set_width(10)
assert pane1['pane_width'] != pane1_width
assert int(pane1['pane_width']) == 10

pane1.reset()
pane1.reset()
Loading