Skip to content

Commit

Permalink
tests(util): Note pydocstyle updates
Browse files Browse the repository at this point in the history
  • Loading branch information
tony committed Dec 17, 2023
1 parent 3225ebd commit 520b8d2
Showing 1 changed file with 12 additions and 4 deletions.
16 changes: 12 additions & 4 deletions tests/test_util.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
"""Tests for utility functions in tmux."""
"""Tests for tmuxp's utility functions."""
import pytest
from libtmux.server import Server

Expand All @@ -9,7 +9,8 @@
from .constants import FIXTURE_PATH


def test_raise_BeforeLoadScriptNotExists_if_not_exists() -> None:
def test_run_before_script_raise_BeforeLoadScriptNotExists_if_not_exists() -> None:
"""run_before_script() raises BeforeLoadScriptNotExists if script not found."""
script_file = FIXTURE_PATH / "script_noexists.sh"

with pytest.raises(BeforeLoadScriptNotExists):
Expand All @@ -19,14 +20,16 @@ def test_raise_BeforeLoadScriptNotExists_if_not_exists() -> None:
run_before_script(script_file)


def test_raise_BeforeLoadScriptError_if_retcode() -> None:
def test_run_before_script_raise_BeforeLoadScriptError_if_retcode() -> None:
"""run_before_script() raises BeforeLoadScriptNotExists if script fails."""
script_file = FIXTURE_PATH / "script_failed.sh"

with pytest.raises(BeforeLoadScriptError):
run_before_script(script_file)


def test_return_stdout_if_ok(capsys: pytest.CaptureFixture[str]) -> None:
"""run_before_script() returns stdout if script succeeds."""
script_file = FIXTURE_PATH / "script_complete.sh"

run_before_script(script_file)
Expand All @@ -35,6 +38,7 @@ def test_return_stdout_if_ok(capsys: pytest.CaptureFixture[str]) -> None:


def test_beforeload_returncode() -> None:
"""run_before_script() returns returncode if script fails."""
script_file = FIXTURE_PATH / "script_failed.sh"

with pytest.raises(exc.BeforeLoadScriptError) as excinfo:
Expand All @@ -43,6 +47,7 @@ def test_beforeload_returncode() -> None:


def test_beforeload_returns_stderr_messages() -> None:
"""run_before_script() returns stderr messages if script fails."""
script_file = FIXTURE_PATH / "script_failed.sh"

with pytest.raises(exc.BeforeLoadScriptError) as excinfo:
Expand All @@ -51,8 +56,10 @@ def test_beforeload_returns_stderr_messages() -> None:


def test_get_session_should_default_to_local_attached_session(
server: Server, monkeypatch: pytest.MonkeyPatch
server: Server,
monkeypatch: pytest.MonkeyPatch,
) -> None:
"""get_session() should launch current terminal's tmux session, if inside one."""
server.new_session(session_name="myfirstsession")
second_session = server.new_session(session_name="mysecondsession")

Expand All @@ -67,6 +74,7 @@ def test_get_session_should_default_to_local_attached_session(
def test_get_session_should_return_first_session_if_no_active_session(
server: Server,
) -> None:
"""get_session() should return first session if no active session."""
first_session = server.new_session(session_name="myfirstsession")
server.new_session(session_name="mysecondsession")

Expand Down

0 comments on commit 520b8d2

Please sign in to comment.