Skip to content

Commit 572ddac

Browse files
#50 add fake fast_print to CharacterBasedErikaMock; add simple test
1 parent a8d5149 commit 572ddac

File tree

2 files changed

+18
-3
lines changed

2 files changed

+18
-3
lines changed

erika/erika_mock.py

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -136,9 +136,6 @@ def _write_byte(self, data, delay=0.5):
136136
def decode(self, value):
137137
raise Exception('Not supported yet')
138138

139-
def fast_print(self, text):
140-
raise Exception('Not supported yet')
141-
142139

143140
# to get exception-safe behavior, make sure __exit__ is always called (by using with-statements)
144141
class CharacterBasedErikaMock(AbstractErikaMock):
@@ -223,6 +220,12 @@ def print_ascii(self, text):
223220
sleep(self.delay_after_each_step)
224221
self.stdscr.refresh()
225222

223+
def fast_print(self, text):
224+
"""just emulates fast printing (doing line splitting + then normal printing)"""
225+
for split in text.splitlines():
226+
self.print_ascii(split)
227+
self.crlf()
228+
226229
def delete_ascii(self, reversed_text):
227230
text_length = len(reversed_text)
228231
if text_length == 0:
@@ -340,5 +343,8 @@ def crlf(self):
340343
def print_ascii(self, text):
341344
raise Exception('Characters and character steps are not supported in microstep-based tests')
342345

346+
def fast_print(self, text):
347+
raise Exception('Characters and character steps are not supported in microstep-based tests')
348+
343349
def delete_ascii(self, text):
344350
raise Exception('Characters and character steps are not supported in microstep-based tests')

tests/erika_mock_unittest.py

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -121,6 +121,15 @@ def test_delete_pixel(self):
121121
my_erika.delete_pixel()
122122
assert_print_output(self, my_erika, ["XXX X"])
123123

124+
def test_fast_print(self):
125+
my_erika = CharacterBasedErikaMock(width=5, height=4, inside_unit_test=True)
126+
lines = "line1\nline2\n\nline4"
127+
128+
my_erika.fast_print(lines)
129+
130+
expected_lines = ["line1", "line2", " ", "line4"]
131+
assert_print_output(self, my_erika, expected_lines)
132+
124133

125134
def main():
126135
unittest.main()

0 commit comments

Comments
 (0)