diff --git a/src/escpos/printer.py b/src/escpos/printer.py index e51eba0..a652b98 100644 --- a/src/escpos/printer.py +++ b/src/escpos/printer.py @@ -312,5 +312,13 @@ class Dummy(Escpos): """ Get the data that was sent to this printer """ return b''.join(self._output_list) + def clear(self): + """ Clear the buffer of the printer + + This method can be called if you send the contents to a physical printer + and want to use the Dummy printer for new output. + """ + del self._output_list[:] + def close(self): pass diff --git a/test/test_function_dummy_clear.py b/test/test_function_dummy_clear.py new file mode 100644 index 0000000..431eb9a --- /dev/null +++ b/test/test_function_dummy_clear.py @@ -0,0 +1,8 @@ +from nose.tools import assert_raises +from escpos.printer import Dummy + +def test_printer_dummy_clear(): + printer = Dummy() + printer.text("Hello") + printer.clear() + assert(printer.output == b'')