diff options
author | Todd Leonhardt <todd.leonhardt@gmail.com> | 2018-09-24 10:22:18 -0400 |
---|---|---|
committer | Todd Leonhardt <todd.leonhardt@gmail.com> | 2018-09-24 10:22:18 -0400 |
commit | 806fe461acee59bcda791a9cb9ebf396af80126e (patch) | |
tree | 9c7763ad6fca4057c06dc8b67c56537b6d960c59 /tests/conftest.py | |
parent | b82015248f4a1c941864c6608ab4457da752df95 (diff) | |
parent | e5e8a7954b9ace78cd49ef43c5f8d6203c227f0f (diff) | |
download | cmd2-git-806fe461acee59bcda791a9cb9ebf396af80126e.tar.gz |
Merged master in to colorize and resolved conflicts
Diffstat (limited to 'tests/conftest.py')
-rw-r--r-- | tests/conftest.py | 26 |
1 files changed, 4 insertions, 22 deletions
diff --git a/tests/conftest.py b/tests/conftest.py index aad2d9f7..39aa3473 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: @@ -107,25 +108,6 @@ quiet: False # Don't print nonessential feedback timing: False # Report execution times """ - -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 isatty(self): - return True - - def normalize(block): """ Normalize a block of text to perform comparison. @@ -138,10 +120,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) @@ -149,7 +131,7 @@ def run_cmd(app, cmd): @fixture def base_app(): c = cmd2.Cmd() - c.stdout = StdOut() + c.stdout = StdSim(c.stdout) return c |