Skip to content

Commit

Permalink
raise exception when TypeError occurs in cashdraw (#268)
Browse files Browse the repository at this point in the history
  • Loading branch information
rakeshgunduka authored and patkan committed Dec 3, 2017
1 parent d1e7052 commit 3c3dab9
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 2 deletions.
1 change: 1 addition & 0 deletions .mailmap
Original file line number Diff line number Diff line change
Expand Up @@ -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>
1 change: 1 addition & 0 deletions AUTHORS
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ mrwunderbar666
Nathan Bookham
Patrick Kanzler
Qian Linfeng
reck31
Renato Lorenzi
Romain Porte
Sam Cheng
Expand Down
4 changes: 2 additions & 2 deletions src/escpos/escpos.py
Original file line number Diff line number Diff line change
Expand Up @@ -697,8 +697,8 @@ def cashdraw(self, pin):
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
Expand Down
19 changes: 19 additions & 0 deletions test/test_function_cashdraw.py
Original file line number Diff line number Diff line change
@@ -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])

0 comments on commit 3c3dab9

Please sign in to comment.