Added basic tests for center feature
This commit is contained in:
parent
dd2ec55bb3
commit
f64c7f6d6a
@ -145,10 +145,8 @@ def test_large_graphics():
|
|||||||
assert(instance.output == b'\x1dv0\x00\x01\x00\x01\x00\xc0\x1dv0\x00\x01\x00\x01\x00\x00')
|
assert(instance.output == b'\x1dv0\x00\x01\x00\x01\x00\xc0\x1dv0\x00\x01\x00\x01\x00\x00')
|
||||||
|
|
||||||
|
|
||||||
def test_width_too_large():
|
@pytest.fixture
|
||||||
"""
|
def dummy_with_width():
|
||||||
Test printing an image that is too large in width.
|
|
||||||
"""
|
|
||||||
instance = printer.Dummy()
|
instance = printer.Dummy()
|
||||||
instance.profile.profile_data = {
|
instance.profile.profile_data = {
|
||||||
'media': {
|
'media': {
|
||||||
@ -157,8 +155,25 @@ def test_width_too_large():
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
return instance
|
||||||
|
|
||||||
|
|
||||||
|
def test_width_too_large(dummy_with_width):
|
||||||
|
"""
|
||||||
|
Test printing an image that is too large in width.
|
||||||
|
"""
|
||||||
|
instance = dummy_with_width
|
||||||
|
|
||||||
with pytest.raises(ImageWidthError):
|
with pytest.raises(ImageWidthError):
|
||||||
instance.image(Image.new("RGB", (385, 200)))
|
instance.image(Image.new("RGB", (385, 200)))
|
||||||
|
|
||||||
instance.image(Image.new("RGB", (384, 200)))
|
instance.image(Image.new("RGB", (384, 200)))
|
||||||
|
|
||||||
|
|
||||||
|
def test_center_image(dummy_with_width):
|
||||||
|
instance = dummy_with_width
|
||||||
|
|
||||||
|
with pytest.raises(ImageWidthError):
|
||||||
|
instance.image(Image.new("RGB", (385, 200)), center=True)
|
||||||
|
|
||||||
|
instance.image(Image.new("RGB", (384, 200)), center=True)
|
||||||
|
@ -13,6 +13,7 @@ from __future__ import division
|
|||||||
from __future__ import print_function
|
from __future__ import print_function
|
||||||
from __future__ import unicode_literals
|
from __future__ import unicode_literals
|
||||||
|
|
||||||
|
import pytest
|
||||||
import mock
|
import mock
|
||||||
|
|
||||||
from escpos.printer import Dummy
|
from escpos.printer import Dummy
|
||||||
@ -30,3 +31,12 @@ def test_type_of_object_passed_to_image_function(img_function):
|
|||||||
d.qr("LoremIpsum")
|
d.qr("LoremIpsum")
|
||||||
args, kwargs = img_function.call_args
|
args, kwargs = img_function.call_args
|
||||||
assert isinstance(args[0], Image.Image)
|
assert isinstance(args[0], Image.Image)
|
||||||
|
|
||||||
|
|
||||||
|
@pytest.fixture
|
||||||
|
def instance():
|
||||||
|
return Dummy()
|
||||||
|
|
||||||
|
|
||||||
|
def test_center(instance):
|
||||||
|
instance.qr("LoremIpsum", center=True)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user