Skip to content

Commit baf5e47

Browse files
committed
Added unit tests
1 parent 4a6171d commit baf5e47

File tree

1 file changed

+22
-0
lines changed

1 file changed

+22
-0
lines changed

tests/test_cmd2.py

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1900,6 +1900,17 @@ def test_alias_create_with_macro_name(base_app, capsys):
19001900
out, err = capsys.readouterr()
19011901
assert "Alias cannot have the same name as a macro" in err
19021902

1903+
def test_alias_that_resolves_into_comment(base_app, capsys):
1904+
# Create the alias
1905+
out = run_cmd(base_app, 'alias create fake ' + constants.COMMENT_CHAR + ' blah blah')
1906+
assert out == normalize("Alias 'fake' created")
1907+
1908+
# Use the alias
1909+
run_cmd(base_app, 'fake')
1910+
out, err = capsys.readouterr()
1911+
assert not out
1912+
assert not err
1913+
19031914
def test_alias_list_invalid_alias(base_app, capsys):
19041915
# Look up invalid alias
19051916
out = run_cmd(base_app, 'alias list invalid')
@@ -2056,6 +2067,17 @@ def test_macro_create_with_missing_unicode_arg_nums(base_app, capsys):
20562067
out, err = capsys.readouterr()
20572068
assert "Not all numbers between 1 and 3" in err
20582069

2070+
def test_macro_that_resolves_into_comment(base_app, capsys):
2071+
# Create the macro
2072+
out = run_cmd(base_app, 'macro create fake {1} blah blah')
2073+
assert out == normalize("Macro 'fake' created")
2074+
2075+
# Use the macro
2076+
run_cmd(base_app, 'fake ' + constants.COMMENT_CHAR)
2077+
out, err = capsys.readouterr()
2078+
assert not out
2079+
assert not err
2080+
20592081
def test_macro_list_invalid_macro(base_app, capsys):
20602082
# Look up invalid macro
20612083
run_cmd(base_app, 'macro list invalid')

0 commit comments

Comments
 (0)