From 9e47ff2505d83469d589b90e50490863a04d4d56 Mon Sep 17 00:00:00 2001 From: Romain Porte Date: Sun, 23 Jul 2017 11:11:22 +0200 Subject: [PATCH] Added test for cut without feed, fixed raw code for it --- src/escpos/escpos.py | 8 ++++++-- test/test_function_cut.py | 17 +++++++++++++++++ 2 files changed, 23 insertions(+), 2 deletions(-) create mode 100644 test/test_function_cut.py diff --git a/src/escpos/escpos.py b/src/escpos/escpos.py index 64e8e05..ef2c026 100644 --- a/src/escpos/escpos.py +++ b/src/escpos/escpos.py @@ -587,8 +587,12 @@ class Escpos(object): :param feed: print and feed before cutting. default: true :raises ValueError: if mode not in ('FULL', 'PART') """ - if feed: - self.print_and_feed(6) + + if not feed: + self._raw(GS + b'V' + six.int2byte(66) + b'\x00') + return + + self.print_and_feed(6) mode = mode.upper() if mode not in ('FULL', 'PART'): diff --git a/test/test_function_cut.py b/test/test_function_cut.py new file mode 100644 index 0000000..d485e0e --- /dev/null +++ b/test/test_function_cut.py @@ -0,0 +1,17 @@ +from __future__ import absolute_import +from __future__ import division +from __future__ import print_function +from __future__ import unicode_literals + +import six + +import escpos.printer as printer +from escpos.constants import GS + + +def test_cut_without_feed(): + """Test cut without feeding paper""" + instance = printer.Dummy() + instance.cut(feed=False) + expected = GS + b'V' + six.int2byte(66) + b'\x00' + assert(instance.output == expected)