Skip to content

Commit 6d2f520

Browse files
committed
Moved some argparse tests from test_transcript.py to test_argparse.py
1 parent c539ef4 commit 6d2f520

File tree

2 files changed

+13
-31
lines changed

2 files changed

+13
-31
lines changed

tests/test_argparse.py

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -119,6 +119,11 @@ def argparse_app():
119119
return app
120120

121121

122+
def test_invalid_syntax(argparse_app, capsys):
123+
run_cmd(argparse_app, 'speak "')
124+
out, err = capsys.readouterr()
125+
assert err == "ERROR: Invalid syntax: No closing quotation\n"
126+
122127
def test_argparse_basic_command(argparse_app):
123128
out = run_cmd(argparse_app, 'say hello')
124129
assert out == ['hello']
@@ -135,6 +140,14 @@ def test_argparse_with_list_and_empty_doc(argparse_app):
135140
out = run_cmd(argparse_app, 'speak -s hello world!')
136141
assert out == ['HELLO WORLD!']
137142

143+
def test_argparse_comment_stripping(argparse_app):
144+
out = run_cmd(argparse_app, 'speak it was /* not */ delicious! # Yuck!')
145+
assert out == ['it was delicious!']
146+
147+
def test_argparser_correct_args_with_quotes_and_midline_options(argparse_app):
148+
out = run_cmd(argparse_app, "speak 'This is a' -s test of the emergency broadcast system!")
149+
assert out == ['THIS IS A TEST OF THE EMERGENCY BROADCAST SYSTEM!']
150+
138151
def test_argparse_quoted_arguments_multiple(argparse_app):
139152
out = run_cmd(argparse_app, 'say "hello there" "rick & morty"')
140153
assert out == ['hello there rick & morty']

tests/test_transcript.py

Lines changed: 0 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -95,13 +95,6 @@ def _cmdline_app():
9595
return c
9696

9797

98-
@pytest.fixture
99-
def _demo_app():
100-
c = DemoApp()
101-
c.stdout = StdOut()
102-
return c
103-
104-
10598
def _get_transcript_blocks(transcript):
10699
cmd = None
107100
expected = ''
@@ -188,24 +181,6 @@ class TestMyAppCase(cmd2.Cmd2TestCase):
188181
CmdApp.testfiles = ['tests/transcript.txt']
189182

190183

191-
def test_comment_stripping(_cmdline_app):
192-
out = run_cmd(_cmdline_app, 'speak it was /* not */ delicious! # Yuck!')
193-
expected = normalize("""it was delicious!""")
194-
assert out == expected
195-
196-
197-
def test_argparser_correct_args_with_quotes_and_midline_options(_cmdline_app):
198-
out = run_cmd(_cmdline_app, "speak 'This is a' -s test of the emergency broadcast system!")
199-
expected = normalize("""THIS IS A TEST OF THE EMERGENCY BROADCAST SYSTEM!""")
200-
assert out == expected
201-
202-
203-
def test_argparser_options_with_spaces_in_quotes(_demo_app):
204-
out = run_cmd(_demo_app, "hello foo -n 'Bugs Bunny' bar baz")
205-
expected = normalize("""Hello Bugs Bunny""")
206-
assert out == expected
207-
208-
209184
def test_commands_at_invocation():
210185
testargs = ["prog", "say hello", "say Gracie", "quit"]
211186
expected = "This is an intro banner ...\nhello\nGracie\n"
@@ -216,12 +191,6 @@ def test_commands_at_invocation():
216191
out = app.stdout.buffer
217192
assert out == expected
218193

219-
def test_invalid_syntax(_cmdline_app, capsys):
220-
run_cmd(_cmdline_app, 'speak "')
221-
out, err = capsys.readouterr()
222-
expected = normalize("""ERROR: Invalid syntax: No closing quotation""")
223-
assert normalize(str(err)) == expected
224-
225194

226195
@pytest.mark.parametrize('filename, feedback_to_output', [
227196
('bol_eol.txt', False),

0 commit comments

Comments
 (0)