diff options
author | Todd Leonhardt <todd.leonhardt@gmail.com> | 2018-02-07 21:50:39 -0500 |
---|---|---|
committer | Todd Leonhardt <todd.leonhardt@gmail.com> | 2018-02-07 21:50:39 -0500 |
commit | f1940dcf474eec60c0459ad29ba9df2590209657 (patch) | |
tree | a48394a97b870dd9ae471b41db92943ec78208f4 /tests/test_submenu.py | |
parent | 73a03c90e9d0e209e36162047061222e09b8a7c7 (diff) | |
download | cmd2-git-f1940dcf474eec60c0459ad29ba9df2590209657.tar.gz |
Added separate test fixture for SecondLevel app by itself
Diffstat (limited to 'tests/test_submenu.py')
-rw-r--r-- | tests/test_submenu.py | 15 |
1 files changed, 11 insertions, 4 deletions
diff --git a/tests/test_submenu.py b/tests/test_submenu.py index 43e4b9d9..9b42f38f 100644 --- a/tests/test_submenu.py +++ b/tests/test_submenu.py @@ -63,6 +63,13 @@ def submenu_app(): second_level_cmd.stdout = StdOut() return app +@pytest.fixture +def secondlevel_app(): + app = SecondLevel() + app.stdout = StdOut() + return app + + def run_submenu_cmd(app, cmd): """ Clear StdOut buffers, run the command, extract the buffer contents.""" app.stdout.clear() @@ -93,9 +100,9 @@ def test_submenu_second_say_from_top_level(submenu_app): assert len(out2) == 1 assert out2[0] == "You called a command in SecondLevel with {!r}.".format(line) -def test_submenu_say_from_second_level(): +def test_submenu_say_from_second_level(secondlevel_app): line = 'testing' - out = run_cmd(second_level_cmd, 'say ' + line) + out = run_cmd(secondlevel_app, 'say ' + line) assert out == ["You called a command in SecondLevel with '%s'." % line] @@ -108,8 +115,8 @@ def test_submenu_help_second_say_from_top_level(submenu_app): assert out2 == ["This is a second level menu. Options are qwe, asd, zxc"] -def test_submenu_help_say_from_second_level(): - out = run_cmd(second_level_cmd, 'help say') +def test_submenu_help_say_from_second_level(secondlevel_app): + out = run_cmd(secondlevel_app, 'help say') assert out == ["This is a second level menu. Options are qwe, asd, zxc"] |