Skip to content

Commit 5340927

Browse files
committed
Added unit tests for new methods of StdSim
1 parent 639bd9b commit 5340927

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed

tests/test_utils.py

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -133,6 +133,7 @@ def test_stdsim_buffer_write_bytes(stdout_sim):
133133
b_str = b'Hello World'
134134
stdout_sim.buffer.write(b_str)
135135
assert stdout_sim.getvalue() == b_str.decode()
136+
assert stdout_sim.getbytes() == b_str
136137

137138
def test_stdsim_buffer_write_str(stdout_sim):
138139
my_str = 'Hello World'
@@ -148,6 +149,15 @@ def test_stdsim_read(stdout_sim):
148149
assert stdout_sim.read() == my_str
149150
assert stdout_sim.getvalue() == ''
150151

152+
def test_stdsim_read_bytes(stdout_sim):
153+
b_str = b'Hello World'
154+
stdout_sim.buffer.write(b_str)
155+
# getbytes() returns the value and leaves it unaffected internally
156+
assert stdout_sim.getbytes() == b_str
157+
# read_bytes() returns the value and then clears the internal buffer
158+
assert stdout_sim.readbytes() == b_str
159+
assert stdout_sim.getbytes() == b''
160+
151161
def test_stdsim_clear(stdout_sim):
152162
my_str = 'Hello World'
153163
stdout_sim.write(my_str)

0 commit comments

Comments
 (0)