Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def test_periods_raise_badsessionname(server, session, session_name, raises):
new_name = session_name + 'moo' # used for rename / switch
if raises:
with pytest.raises(exc.BadSessionName):
session.rename_session(new_name)
with pytest.raises(exc.BadSessionName):
server.new_session(session_name)
with pytest.raises(exc.BadSessionName):
server.has_session(session_name)
with pytest.raises(exc.BadSessionName):
server.switch_client(new_name)
with pytest.raises(exc.BadSessionName):
server.attach_session(new_name)
else:
server.new_session(session_name)
def test_regression_00132_session_name_with_dots(tmpdir, server, session):
yaml_config = curjoin("workspacebuilder/regression_00132_dots.yaml")
cli_args = [yaml_config]
inputs = []
runner = CliRunner()
result = runner.invoke(
cli.command_load, cli_args, input=''.join(inputs), standalone_mode=False
)
assert result.exception
assert isinstance(result.exception, libtmux.exc.BadSessionName)
def test_periods_raise_badsessionname(server, session, session_name, raises):
new_name = session_name + 'moo' # used for rename / switch
if raises:
with pytest.raises(exc.BadSessionName):
session.rename_session(new_name)
with pytest.raises(exc.BadSessionName):
server.new_session(session_name)
with pytest.raises(exc.BadSessionName):
server.has_session(session_name)
with pytest.raises(exc.BadSessionName):
server.switch_client(new_name)
with pytest.raises(exc.BadSessionName):
server.attach_session(new_name)
else:
server.new_session(session_name)
server.has_session(session_name)
session.rename_session(new_name)
with pytest.raises(exc.LibTmuxException):
def test_session_check_name(session_name, raises, exc_msg_regex):
if raises:
with pytest.raises(BadSessionName) as exc_info:
session_check_name(session_name)
assert exc_info.match(exc_msg_regex)
else:
session_check_name(session_name)
session_name : str
Name of session.
Raises
------
:exc:`exc.BadSessionName`
Invalid session name.
"""
if not session_name or len(session_name) == 0:
raise exc.BadSessionName("tmux session names may not be empty.")
elif '.' in session_name:
raise exc.BadSessionName(
"tmux session name \"%s\" may not contain periods.", session_name
)
elif ':' in session_name:
raise exc.BadSessionName(
"tmux session name \"%s\" may not contain colons.", session_name
)
tmux(1) session names may not be empty, or include periods or colons.
These delimiters are reserved for noting session, window and pane.
Parameters
----------
session_name : str
Name of session.
Raises
------
:exc:`exc.BadSessionName`
Invalid session name.
"""
if not session_name or len(session_name) == 0:
raise exc.BadSessionName("tmux session names may not be empty.")
elif '.' in session_name:
raise exc.BadSessionName(
"tmux session name \"%s\" may not contain periods.", session_name
)
elif ':' in session_name:
raise exc.BadSessionName(
"tmux session name \"%s\" may not contain colons.", session_name
)
These delimiters are reserved for noting session, window and pane.
Parameters
----------
session_name : str
Name of session.
Raises
------
:exc:`exc.BadSessionName`
Invalid session name.
"""
if not session_name or len(session_name) == 0:
raise exc.BadSessionName("tmux session names may not be empty.")
elif '.' in session_name:
raise exc.BadSessionName(
"tmux session name \"%s\" may not contain periods.", session_name
)
elif ':' in session_name:
raise exc.BadSessionName(
"tmux session name \"%s\" may not contain colons.", session_name
)