Added test for cut without feed, fixed raw code for it

This commit is contained in:
Romain Porte 2017-07-23 11:11:22 +02:00 committed by Patrick Kanzler
parent 9bc3b30a60
commit 9e47ff2505
2 changed files with 23 additions and 2 deletions

View File

@ -587,8 +587,12 @@ class Escpos(object):
:param feed: print and feed before cutting. default: true :param feed: print and feed before cutting. default: true
:raises ValueError: if mode not in ('FULL', 'PART') :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() mode = mode.upper()
if mode not in ('FULL', 'PART'): if mode not in ('FULL', 'PART'):

17
test/test_function_cut.py Normal file
View File

@ -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)