How to use the libtmux.Session function in libtmux

To help you get started, we’ve selected a few libtmux examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github tmux-python / libtmux / tests / test_session.py View on Github external
def test_new_session(server):
    """Server.new_session creates new session."""
    new_session_name = TEST_SESSION_PREFIX + next(namer)
    new_session = server.new_session(session_name=new_session_name, detach=True)

    assert isinstance(new_session, Session)
    assert new_session.get('session_name') == new_session_name
github tmux-python / libtmux / tests / test_tmuxobject.py View on Github external
def test_find_where_multiple_infos(server, session):
    """.find_where returns objects with multiple attributes."""

    for session in server.sessions:
        session_id = session.get('session_id')
        session_name = session.get('session_name')
        find_where = server.find_where(
            {'session_id': session_id, 'session_name': session_name}
        )

        assert find_where == session
        assert isinstance(find_where, Session)

        # session.find_where
        for window in session.windows:
            window_id = window.get('window_id')
            window_index = window.get('window_index')

            find_where = session.find_where(
                {'window_id': window_id, 'window_index': window_index}
            )

            assert find_where == window
            assert isinstance(find_where, Window)

            # window.find_where
            for pane in window.panes:
                pane_id = pane.get('pane_id')
github tmux-python / tmuxp / tests / test_cli.py View on Github external
projfile.write(
        """
session_name: samplesimple
start_directory: './'
windows:
- panes:
    - echo 'hey'"""
    )

    # open it detached
    session = load_workspace(
        projfile.strpath, socket_name=server.socket_name, detached=True
    )
    pane = session.attached_window.attached_pane

    assert isinstance(session, libtmux.Session)
    assert session.name == 'samplesimple'
    assert pane.current_path == realtemp.strpath
github tmux-python / libtmux / tests / test_tmuxobject.py View on Github external
def test_find_where(server, session):
    """Test that find_where() retrieves single matching object."""
    # server.find_where
    for session in server.sessions:
        session_id = session.get('session_id')

        assert server.find_where({'session_id': session_id}) == session
        assert isinstance(server.find_where({'session_id': session_id}), Session)

        # session.find_where
        for window in session.windows:
            window_id = window.get('window_id')

            assert session.find_where({'window_id': window_id}) == window
            assert isinstance(session.find_where({'window_id': window_id}), Window)

            # window.find_where
            for pane in window.panes:
                pane_id = pane.get('pane_id')

                assert window.find_where({'pane_id': pane_id}) == pane
                assert isinstance(window.find_where({'pane_id': pane_id}), Pane)
github tmux-python / tmuxp / tests / test_tmuxobject.py View on Github external
def test_findWhere(server, session):
    """Test that findWhere() retrieves single matching object."""
    # server.findWhere
    for session in server.sessions:
        session_id = session.get('session_id')

        assert server.findWhere({'session_id': session_id}) == session
        assert isinstance(server.findWhere({
            'session_id': session_id
        }), Session)

        # session.findWhere
        for window in session.windows:
            window_id = window.get('window_id')

            assert session.findWhere({'window_id': window_id}) == window
            assert isinstance(
                session.findWhere({'window_id': window_id}), Window
            )

            # window.findWhere
            for pane in window.panes:
                pane_id = pane.get('pane_id')

                assert window.findWhere({'pane_id': pane_id}) == pane
                assert isinstance(
github tmux-python / tmuxp / tests / test_session.py View on Github external
def test_new_session(server):
    """Server.new_session creates new session."""
    new_session_name = TEST_SESSION_PREFIX + next(namer)
    new_session = server.new_session(
        session_name=new_session_name, detach=True)

    assert isinstance(new_session, Session)
    assert new_session.get('session_name') == new_session_name
github tmux-python / tmuxp / tests / test_tmuxobject.py View on Github external
def test_findWhere_multiple_attrs(server, session):
    """.findWhere returns objects with multiple attributes."""

    for session in server.sessions:
        session_id = session.get('session_id')
        session_name = session.get('session_name')
        find_where = server.findWhere({
            'session_id': session_id,
            'session_name': session_name
        })

        assert find_where == session
        assert isinstance(find_where, Session)

        # session.findWhere
        for window in session.windows:
            window_id = window.get('window_id')
            window_index = window.get('window_index')

            find_where = session.findWhere({
                'window_id': window_id,
                'window_index': window_index
            })

            assert find_where == window
            assert isinstance(find_where, Window)

            # window.findWhere
            for pane in window.panes:
github tmux-python / tmuxp / tests / test_cli.py View on Github external
def test_load_workspace(server, monkeypatch):
    # this is an implementation test. Since this testsuite may be ran within
    # a tmux session by the developer himself, delete the TMUX variable
    # temporarily.
    monkeypatch.delenv('TMUX', raising=False)
    session_file = curjoin("workspacebuilder/two_pane.yaml")

    # open it detached
    session = load_workspace(
        session_file, socket_name=server.socket_name, detached=True
    )

    assert isinstance(session, libtmux.Session)
    assert session.name == 'sampleconfig'