mirror of
https://github.com/python-escpos/python-escpos
synced 2025-09-13 09:09:58 +00:00
reformat codebase
This commit is contained in:
@@ -22,13 +22,13 @@ def test_bit_image_black():
|
||||
Test printing solid black bit image (raster)
|
||||
"""
|
||||
instance = printer.Dummy()
|
||||
instance.image('test/resources/canvas_black.png', impl="bitImageRaster")
|
||||
assert(instance.output == b'\x1dv0\x00\x01\x00\x01\x00\x80')
|
||||
instance.image("test/resources/canvas_black.png", impl="bitImageRaster")
|
||||
assert instance.output == b"\x1dv0\x00\x01\x00\x01\x00\x80"
|
||||
# Same thing w/ object created on the fly, rather than a filename
|
||||
instance = printer.Dummy()
|
||||
im = Image.new("RGB", (1, 1), (0, 0, 0))
|
||||
instance.image(im, impl="bitImageRaster")
|
||||
assert(instance.output == b'\x1dv0\x00\x01\x00\x01\x00\x80')
|
||||
assert instance.output == b"\x1dv0\x00\x01\x00\x01\x00\x80"
|
||||
|
||||
|
||||
def test_bit_image_white():
|
||||
@@ -36,8 +36,8 @@ def test_bit_image_white():
|
||||
Test printing solid white bit image (raster)
|
||||
"""
|
||||
instance = printer.Dummy()
|
||||
instance.image('test/resources/canvas_white.png', impl="bitImageRaster")
|
||||
assert(instance.output == b'\x1dv0\x00\x01\x00\x01\x00\x00')
|
||||
instance.image("test/resources/canvas_white.png", impl="bitImageRaster")
|
||||
assert instance.output == b"\x1dv0\x00\x01\x00\x01\x00\x00"
|
||||
|
||||
|
||||
def test_bit_image_both():
|
||||
@@ -45,8 +45,8 @@ def test_bit_image_both():
|
||||
Test printing black/white bit image (raster)
|
||||
"""
|
||||
instance = printer.Dummy()
|
||||
instance.image('test/resources/black_white.png', impl="bitImageRaster")
|
||||
assert(instance.output == b'\x1dv0\x00\x01\x00\x02\x00\xc0\x00')
|
||||
instance.image("test/resources/black_white.png", impl="bitImageRaster")
|
||||
assert instance.output == b"\x1dv0\x00\x01\x00\x02\x00\xc0\x00"
|
||||
|
||||
|
||||
def test_bit_image_transparent():
|
||||
@@ -54,8 +54,8 @@ def test_bit_image_transparent():
|
||||
Test printing black/transparent bit image (raster)
|
||||
"""
|
||||
instance = printer.Dummy()
|
||||
instance.image('test/resources/black_transparent.png', impl="bitImageRaster")
|
||||
assert(instance.output == b'\x1dv0\x00\x01\x00\x02\x00\xc0\x00')
|
||||
instance.image("test/resources/black_transparent.png", impl="bitImageRaster")
|
||||
assert instance.output == b"\x1dv0\x00\x01\x00\x02\x00\xc0\x00"
|
||||
|
||||
|
||||
# Column format print
|
||||
@@ -64,8 +64,8 @@ def test_bit_image_colfmt_black():
|
||||
Test printing solid black bit image (column format)
|
||||
"""
|
||||
instance = printer.Dummy()
|
||||
instance.image('test/resources/canvas_black.png', impl="bitImageColumn")
|
||||
assert(instance.output == b'\x1b3\x10\x1b*!\x01\x00\x80\x00\x00\x0a\x1b2')
|
||||
instance.image("test/resources/canvas_black.png", impl="bitImageColumn")
|
||||
assert instance.output == b"\x1b3\x10\x1b*!\x01\x00\x80\x00\x00\x0a\x1b2"
|
||||
|
||||
|
||||
def test_bit_image_colfmt_white():
|
||||
@@ -73,8 +73,8 @@ def test_bit_image_colfmt_white():
|
||||
Test printing solid white bit image (column format)
|
||||
"""
|
||||
instance = printer.Dummy()
|
||||
instance.image('test/resources/canvas_white.png', impl="bitImageColumn")
|
||||
assert(instance.output == b'\x1b3\x10\x1b*!\x01\x00\x00\x00\x00\x0a\x1b2')
|
||||
instance.image("test/resources/canvas_white.png", impl="bitImageColumn")
|
||||
assert instance.output == b"\x1b3\x10\x1b*!\x01\x00\x00\x00\x00\x0a\x1b2"
|
||||
|
||||
|
||||
def test_bit_image_colfmt_both():
|
||||
@@ -82,8 +82,10 @@ def test_bit_image_colfmt_both():
|
||||
Test printing black/white bit image (column format)
|
||||
"""
|
||||
instance = printer.Dummy()
|
||||
instance.image('test/resources/black_white.png', impl="bitImageColumn")
|
||||
assert(instance.output == b'\x1b3\x10\x1b*!\x02\x00\x80\x00\x00\x80\x00\x00\x0a\x1b2')
|
||||
instance.image("test/resources/black_white.png", impl="bitImageColumn")
|
||||
assert (
|
||||
instance.output == b"\x1b3\x10\x1b*!\x02\x00\x80\x00\x00\x80\x00\x00\x0a\x1b2"
|
||||
)
|
||||
|
||||
|
||||
def test_bit_image_colfmt_transparent():
|
||||
@@ -91,8 +93,10 @@ def test_bit_image_colfmt_transparent():
|
||||
Test printing black/transparent bit image (column format)
|
||||
"""
|
||||
instance = printer.Dummy()
|
||||
instance.image('test/resources/black_transparent.png', impl="bitImageColumn")
|
||||
assert(instance.output == b'\x1b3\x10\x1b*!\x02\x00\x80\x00\x00\x80\x00\x00\x0a\x1b2')
|
||||
instance.image("test/resources/black_transparent.png", impl="bitImageColumn")
|
||||
assert (
|
||||
instance.output == b"\x1b3\x10\x1b*!\x02\x00\x80\x00\x00\x80\x00\x00\x0a\x1b2"
|
||||
)
|
||||
|
||||
|
||||
# Graphics print
|
||||
@@ -101,8 +105,11 @@ def test_graphics_black():
|
||||
Test printing solid black graphics
|
||||
"""
|
||||
instance = printer.Dummy()
|
||||
instance.image('test/resources/canvas_black.png', impl="graphics")
|
||||
assert(instance.output == b'\x1d(L\x0b\x000p0\x01\x011\x01\x00\x01\x00\x80\x1d(L\x02\x0002')
|
||||
instance.image("test/resources/canvas_black.png", impl="graphics")
|
||||
assert (
|
||||
instance.output
|
||||
== b"\x1d(L\x0b\x000p0\x01\x011\x01\x00\x01\x00\x80\x1d(L\x02\x0002"
|
||||
)
|
||||
|
||||
|
||||
def test_graphics_white():
|
||||
@@ -110,8 +117,11 @@ def test_graphics_white():
|
||||
Test printing solid white graphics
|
||||
"""
|
||||
instance = printer.Dummy()
|
||||
instance.image('test/resources/canvas_white.png', impl="graphics")
|
||||
assert(instance.output == b'\x1d(L\x0b\x000p0\x01\x011\x01\x00\x01\x00\x00\x1d(L\x02\x0002')
|
||||
instance.image("test/resources/canvas_white.png", impl="graphics")
|
||||
assert (
|
||||
instance.output
|
||||
== b"\x1d(L\x0b\x000p0\x01\x011\x01\x00\x01\x00\x00\x1d(L\x02\x0002"
|
||||
)
|
||||
|
||||
|
||||
def test_graphics_both():
|
||||
@@ -119,8 +129,11 @@ def test_graphics_both():
|
||||
Test printing black/white graphics
|
||||
"""
|
||||
instance = printer.Dummy()
|
||||
instance.image('test/resources/black_white.png', impl="graphics")
|
||||
assert(instance.output == b'\x1d(L\x0c\x000p0\x01\x011\x02\x00\x02\x00\xc0\x00\x1d(L\x02\x0002')
|
||||
instance.image("test/resources/black_white.png", impl="graphics")
|
||||
assert (
|
||||
instance.output
|
||||
== b"\x1d(L\x0c\x000p0\x01\x011\x02\x00\x02\x00\xc0\x00\x1d(L\x02\x0002"
|
||||
)
|
||||
|
||||
|
||||
def test_graphics_transparent():
|
||||
@@ -128,8 +141,11 @@ def test_graphics_transparent():
|
||||
Test printing black/transparent graphics
|
||||
"""
|
||||
instance = printer.Dummy()
|
||||
instance.image('test/resources/black_transparent.png', impl="graphics")
|
||||
assert(instance.output == b'\x1d(L\x0c\x000p0\x01\x011\x02\x00\x02\x00\xc0\x00\x1d(L\x02\x0002')
|
||||
instance.image("test/resources/black_transparent.png", impl="graphics")
|
||||
assert (
|
||||
instance.output
|
||||
== b"\x1d(L\x0c\x000p0\x01\x011\x02\x00\x02\x00\xc0\x00\x1d(L\x02\x0002"
|
||||
)
|
||||
|
||||
|
||||
def test_large_graphics():
|
||||
@@ -137,20 +153,19 @@ def test_large_graphics():
|
||||
Test whether 'large' graphics that induce a fragmentation are handled correctly.
|
||||
"""
|
||||
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')
|
||||
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"
|
||||
)
|
||||
|
||||
|
||||
@pytest.fixture
|
||||
def dummy_with_width():
|
||||
instance = printer.Dummy()
|
||||
instance.profile.profile_data = {
|
||||
'media': {
|
||||
'width': {
|
||||
'pixels': 384
|
||||
}
|
||||
}
|
||||
}
|
||||
instance.profile.profile_data = {"media": {"width": {"pixels": 384}}}
|
||||
return instance
|
||||
|
||||
|
||||
|
Reference in New Issue
Block a user