diff options
author | Kevin Van Brunt <kmvanbrunt@gmail.com> | 2018-09-25 18:16:22 -0400 |
---|---|---|
committer | Kevin Van Brunt <kmvanbrunt@gmail.com> | 2018-09-25 18:16:22 -0400 |
commit | 45d2398b3023543ed1615115db5d35b1fd65dc5b (patch) | |
tree | c2af42bab5f3aacdd507dcaea801581a306d0a92 /tests/conftest.py | |
parent | 7cc94ab98c007210b344fbb1af965570fae63959 (diff) | |
parent | dac03119e5932f8a34a1318122e2f45fa875084c (diff) | |
download | cmd2-git-45d2398b3023543ed1615115db5d35b1fd65dc5b.tar.gz |
Merge branch 'master' into command_help_noflag
Diffstat (limited to 'tests/conftest.py')
-rw-r--r-- | tests/conftest.py | 22 |
1 files changed, 4 insertions, 18 deletions
diff --git a/tests/conftest.py b/tests/conftest.py index a85135b9..561f281b 100644 --- a/tests/conftest.py +++ b/tests/conftest.py @@ -12,6 +12,7 @@ from unittest import mock from pytest import fixture import cmd2 +from cmd2.utils import StdSim # Prefer statically linked gnureadline if available (for macOS compatibility due to issues with libedit) try: @@ -115,21 +116,6 @@ timing: False # Report execution times """.format(color_str) -class StdOut(object): - """ Toy class for replacing self.stdout in cmd2.Cmd instances for unit testing. """ - def __init__(self): - self.buffer = '' - - def write(self, s): - self.buffer += s - - def read(self): - raise NotImplementedError - - def clear(self): - self.buffer = '' - - def normalize(block): """ Normalize a block of text to perform comparison. @@ -142,10 +128,10 @@ def normalize(block): def run_cmd(app, cmd): - """ Clear StdOut buffer, run the command, extract the buffer contents, """ + """ Clear StdSim buffer, run the command, extract the buffer contents, """ app.stdout.clear() app.onecmd_plus_hooks(cmd) - out = app.stdout.buffer + out = app.stdout.getvalue() app.stdout.clear() return normalize(out) @@ -153,7 +139,7 @@ def run_cmd(app, cmd): @fixture def base_app(): c = cmd2.Cmd() - c.stdout = StdOut() + c.stdout = StdSim(c.stdout) return c |