diff options
| author | Todd Leonhardt <tleonhardt@gmail.com> | 2017-04-26 15:47:17 -0400 |
|---|---|---|
| committer | Todd Leonhardt <tleonhardt@gmail.com> | 2017-04-26 15:47:17 -0400 |
| commit | f3fa2265442b5c263f7f7f9a99da80142d9a3fd4 (patch) | |
| tree | f9181f73a3b7edbc940fd63553c85a98af7fdc23 /tests/test_cmd2.py | |
| parent | 90330f29a7fd1ebf03ef2b639f8bc44caf5c379a (diff) | |
| download | cmd2-git-f3fa2265442b5c263f7f7f9a99da80142d9a3fd4.tar.gz | |
Fixed transcript testing issues
Transcript testing no longer creates an unnecessary 2nd instance of the class derived from cmd2.Cmd. This dramatically simplifies transcript testing for derived classes which have required parameters during construction.
As a side effect the, feedback_to_output attribute now defaults to false. This had some minor ripple effects on various unit tests.
Diffstat (limited to 'tests/test_cmd2.py')
| -rw-r--r-- | tests/test_cmd2.py | 18 |
1 files changed, 8 insertions, 10 deletions
diff --git a/tests/test_cmd2.py b/tests/test_cmd2.py index 99409d46..10ae4329 100644 --- a/tests/test_cmd2.py +++ b/tests/test_cmd2.py @@ -266,16 +266,15 @@ _relative_load {} assert out == expected -def test_base_save(base_app, capsys): +def test_base_save(base_app): # TODO: Use a temporary directory for the file filename = 'deleteme.txt' run_cmd(base_app, 'help') run_cmd(base_app, 'help save') # Test the * form of save which saves all commands from history - run_cmd(base_app, 'save * {}'.format(filename)) - out, err = capsys.readouterr() - assert out == 'Saved to {}\n'.format(filename) + out = run_cmd(base_app, 'save * {}'.format(filename)) + assert out == normalize('Saved to {}\n'.format(filename)) expected = normalize(""" help @@ -288,18 +287,16 @@ save * deleteme.txt assert content == expected # Test the N form of save which saves a numbered command from history - run_cmd(base_app, 'save 1 {}'.format(filename)) - out, err = capsys.readouterr() - assert out == 'Saved to {}\n'.format(filename) + out = run_cmd(base_app, 'save 1 {}'.format(filename)) + assert out == normalize('Saved to {}\n'.format(filename)) expected = normalize('help') with open(filename) as f: content = normalize(f.read()) assert content == expected # Test the blank form of save which saves the most recent command from history - run_cmd(base_app, 'save {}'.format(filename)) - out, err = capsys.readouterr() - assert out == 'Saved to {}\n'.format(filename) + out = run_cmd(base_app, 'save {}'.format(filename)) + assert out == normalize('Saved to {}\n'.format(filename)) expected = normalize('save 1 {}'.format(filename)) with open(filename) as f: content = normalize(f.read()) @@ -397,6 +394,7 @@ def test_send_to_paste_buffer(base_app): def test_base_timing(base_app, capsys): + base_app.feedback_to_output = False out = run_cmd(base_app, 'set timing True') expected = normalize("""timing - was: False now: True |
