mirror of
https://github.com/python-escpos/python-escpos
synced 2025-08-24 09:03:34 +00:00
Added ImageWidthError and its implementation (#226)
* Added ImageWidthError and its implementation * Added unit tests for ImageWidthError * Parse max_width to int before compare
This commit is contained in:

committed by
Patrick Kanzler

parent
5bf2636753
commit
c4dd4f2960
@@ -12,9 +12,13 @@ from __future__ import division
|
||||
from __future__ import print_function
|
||||
from __future__ import unicode_literals
|
||||
|
||||
import escpos.printer as printer
|
||||
import pytest
|
||||
|
||||
from PIL import Image
|
||||
|
||||
import escpos.printer as printer
|
||||
from escpos.exceptions import ImageWidthError
|
||||
|
||||
|
||||
# Raster format print
|
||||
def test_bit_image_black():
|
||||
@@ -139,3 +143,22 @@ def test_large_graphics():
|
||||
instance = printer.Dummy()
|
||||
instance.image('test/resources/black_white.png', impl="bitImageRaster", fragment_height=1)
|
||||
assert(instance.output == b'\x1dv0\x00\x01\x00\x01\x00\xc0\x1dv0\x00\x01\x00\x01\x00\x00')
|
||||
|
||||
|
||||
def test_width_too_large():
|
||||
"""
|
||||
Test printing an image that is too large in width.
|
||||
"""
|
||||
instance = printer.Dummy()
|
||||
instance.profile.profile_data = {
|
||||
'media': {
|
||||
'width': {
|
||||
'pixels': 384
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
with pytest.raises(ImageWidthError):
|
||||
instance.image(Image.new("RGB", (385, 200)))
|
||||
|
||||
instance.image(Image.new("RGB", (384, 200)))
|
Reference in New Issue
Block a user