diff options
author | Todd Leonhardt <todd.leonhardt@gmail.com> | 2018-10-03 12:06:53 -0400 |
---|---|---|
committer | Todd Leonhardt <todd.leonhardt@gmail.com> | 2018-10-03 12:06:53 -0400 |
commit | 5340927f72edde44a56f5193069f810673d0c002 (patch) | |
tree | a31b67cf62cdd8bb2626481d5301f2e486922b9c /tests/test_utils.py | |
parent | 639bd9b03f01304bce51f68c26baba24c354db90 (diff) | |
download | cmd2-git-5340927f72edde44a56f5193069f810673d0c002.tar.gz |
Added unit tests for new methods of StdSim
Diffstat (limited to 'tests/test_utils.py')
-rw-r--r-- | tests/test_utils.py | 10 |
1 files changed, 10 insertions, 0 deletions
diff --git a/tests/test_utils.py b/tests/test_utils.py index 53031567..43a05a9a 100644 --- a/tests/test_utils.py +++ b/tests/test_utils.py @@ -133,6 +133,7 @@ def test_stdsim_buffer_write_bytes(stdout_sim): b_str = b'Hello World' stdout_sim.buffer.write(b_str) assert stdout_sim.getvalue() == b_str.decode() + assert stdout_sim.getbytes() == b_str def test_stdsim_buffer_write_str(stdout_sim): my_str = 'Hello World' @@ -148,6 +149,15 @@ def test_stdsim_read(stdout_sim): assert stdout_sim.read() == my_str assert stdout_sim.getvalue() == '' +def test_stdsim_read_bytes(stdout_sim): + b_str = b'Hello World' + stdout_sim.buffer.write(b_str) + # getbytes() returns the value and leaves it unaffected internally + assert stdout_sim.getbytes() == b_str + # read_bytes() returns the value and then clears the internal buffer + assert stdout_sim.readbytes() == b_str + assert stdout_sim.getbytes() == b'' + def test_stdsim_clear(stdout_sim): my_str = 'Hello World' stdout_sim.write(my_str) |