raise exception when TypeError occurs in cashdraw (#268)

This commit is contained in:
reck 2017-12-04 03:51:29 +05:30 committed by Patrick Kanzler
parent d1e7052fa1
commit 3c3dab95f5
4 changed files with 23 additions and 2 deletions

View File

@ -10,3 +10,4 @@ Ahmed Tahri <nyuubi.10@gmail.com> TAHRI Ahmed <nyuubi.10@gmai
Michael Elsdörfer <michael@elsdoerfer.com> Michael Elsdörfer <michael@elsdoerfer.info>
csoft2k <csoft2k@hotmail.com>
Sergio Pulgarin <sergio.pulgarin@gmail.com>
reck31 <rakesh.gunduka@gmail.com>

View File

@ -20,6 +20,7 @@ mrwunderbar666
Nathan Bookham
Patrick Kanzler
Qian Linfeng
reck31
Renato Lorenzi
Romain Porte
Sam Cheng

View File

@ -697,8 +697,8 @@ class Escpos(object):
else:
try:
self._raw(CD_KICK_DEC_SEQUENCE(*pin))
except:
raise CashDrawerError()
except TypeError as err:
raise CashDrawerError(err)
def linedisplay_select(self, select_display=False):
""" Selects the line display or the printer

View File

@ -0,0 +1,19 @@
#!/usr/bin/python
from __future__ import absolute_import
from __future__ import division
from __future__ import print_function
from __future__ import unicode_literals
import escpos.printer as printer
from escpos.exceptions import CashDrawerError
import pytest
def test_raise_CashDrawerError():
"""should raise an error if the sequence is invalid.
"""
instance = printer.Dummy()
with pytest.raises(CashDrawerError):
# call with sequence that is too long
instance.cashdraw([1,1,1,1,1,1])