Skip to content

Commit 189df55

Browse files
committed
Updating unit tests
1 parent d91943f commit 189df55

File tree

1 file changed

+15
-0
lines changed

1 file changed

+15
-0
lines changed

tests/test_cmd2.py

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2360,6 +2360,21 @@ def test_startup_script(request):
23602360
assert 'alias create ls' in out[0]
23612361

23622362

2363+
@pytest.mark.parametrize('startup_script', odd_file_names)
2364+
def test_startup_script_with_odd_file_names(startup_script):
2365+
"""Test file names with various patterns"""
2366+
# Mock os.path.exists to trick cmd2 into adding this script to its startup commands
2367+
saved_exists = os.path.exists
2368+
os.path.exists = mock.MagicMock(name='exists', return_value=True)
2369+
2370+
app = cmd2.Cmd(allow_cli_args=False, startup_script=startup_script)
2371+
assert len(app._startup_commands) == 1
2372+
assert app._startup_commands[0] == "run_script {}".format(utils.quote_string(os.path.abspath(startup_script)))
2373+
2374+
# Restore os.path.exists
2375+
os.path.exists = saved_exists
2376+
2377+
23632378
def test_transcripts_at_init():
23642379
transcript_files = ['foo', 'bar']
23652380
app = cmd2.Cmd(allow_cli_args=False, transcript_files=transcript_files)

0 commit comments

Comments
 (0)