Skip to content

Commit 710db8f

Browse files
committed
Renamed function.
1 parent 06dc8b7 commit 710db8f

File tree

2 files changed

+10
-10
lines changed

2 files changed

+10
-10
lines changed

cmd2/cmd2.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -464,9 +464,9 @@ def __init__(
464464
self._persistent_history_length = persistent_history_length
465465
self._initialize_history(persistent_history_file)
466466

467-
# Initialize the main PromptSession
467+
# Create the main PromptSession
468468
self.bottom_toolbar = bottom_toolbar
469-
self.main_session = self._initialize_main_session(auto_suggest, completekey)
469+
self.main_session = self._create_main_session(auto_suggest, completekey)
470470

471471
# The session currently holding focus (either the main REPL or a command's
472472
# custom prompt). Completion and UI logic should reference this variable
@@ -644,8 +644,8 @@ def __init__(
644644
# the current command being executed
645645
self.current_command: Statement | None = None
646646

647-
def _initialize_main_session(self, auto_suggest: bool, completekey: str) -> PromptSession[str]:
648-
"""Initialize and return the core PromptSession for the application.
647+
def _create_main_session(self, auto_suggest: bool, completekey: str) -> PromptSession[str]:
648+
"""Create and return the main PromptSession for the application.
649649
650650
Builds an interactive session if stdin is a TTY. Otherwise, uses
651651
dummy drivers to support non-interactive streams like pipes or files.
@@ -3229,7 +3229,7 @@ def _is_tty_session(session: PromptSession[str]) -> bool:
32293229
running in a headless environment (DummyInput).
32303230
"""
32313231
# Validate against the session's assigned input driver rather than sys.stdin.
3232-
# This respects the fallback logic in _initialize_session() and allows unit
3232+
# This respects the fallback logic in _create_main_session() and allows unit
32333233
# tests to inject PipeInput for programmatic interaction.
32343234
return not isinstance(session.input, DummyInput)
32353235

tests/test_cmd2.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3670,7 +3670,7 @@ def test_custom_completekey_ctrl_k():
36703670
assert found, "Could not find binding for 'c-k' (Keys.ControlK) in session key bindings"
36713671

36723672

3673-
def test_init_main_session_exception(monkeypatch):
3673+
def test_create_main_session_exception(monkeypatch):
36743674

36753675
# Mock PromptSession to raise ValueError on first call, then succeed
36763676
valid_session_mock = mock.MagicMock(spec=PromptSession)
@@ -3758,7 +3758,7 @@ def test_multiline_complete_statement_keyboard_interrupt(multiline_app, monkeypa
37583758
poutput_mock.assert_called_with('^C')
37593759

37603760

3761-
def test_init_main_session_no_console_error(monkeypatch):
3761+
def test_create_main_session_no_console_error(monkeypatch):
37623762
from cmd2.cmd2 import NoConsoleScreenBufferError
37633763

37643764
# Mock PromptSession to raise NoConsoleScreenBufferError on first call, then succeed
@@ -3778,7 +3778,7 @@ def test_init_main_session_no_console_error(monkeypatch):
37783778
assert isinstance(kwargs['output'], DummyOutput)
37793779

37803780

3781-
def test_init_main_session_with_custom_tty() -> None:
3781+
def test_create_main_session_with_custom_tty() -> None:
37823782
# Create a mock stdin with says it's a TTY
37833783
custom_stdin = mock.MagicMock(spec=io.TextIOWrapper)
37843784
custom_stdin.isatty.return_value = True
@@ -3796,13 +3796,13 @@ def test_init_main_session_with_custom_tty() -> None:
37963796
app = cmd2.Cmd()
37973797
app.stdin = custom_stdin
37983798
app.stdout = custom_stdout
3799-
app._initialize_main_session(auto_suggest=True, completekey=app.DEFAULT_COMPLETEKEY)
3799+
app._create_main_session(auto_suggest=True, completekey=app.DEFAULT_COMPLETEKEY)
38003800

38013801
mock_create_input.assert_called_once_with(stdin=custom_stdin)
38023802
mock_create_output.assert_called_once_with(stdout=custom_stdout)
38033803

38043804

3805-
def test_init_main_session_non_interactive() -> None:
3805+
def test_create_main_session_non_interactive() -> None:
38063806
# Set up a mock for a non-TTY stream (like a pipe)
38073807
mock_stdin = mock.MagicMock(spec=io.TextIOWrapper)
38083808
mock_stdin.isatty.return_value = False

0 commit comments

Comments
 (0)