From 59dccd79dac80e9e985a1ed90887e6deeb21761f Mon Sep 17 00:00:00 2001 From: Patrick Kanzler Date: Sun, 7 Aug 2016 14:39:58 +0200 Subject: [PATCH] test add test for image-splitting-method --- test/test_image.py | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/test/test_image.py b/test/test_image.py index dbfe5b0..6fda6dd 100644 --- a/test/test_image.py +++ b/test/test_image.py @@ -43,6 +43,20 @@ def test_image_white(): _load_and_check_img('canvas_white.' + img_format, 1, 1, b'\x00', [b'\x00']) +def test_split(): + """ + test whether the split-function works as expected + """ + im = EscposImage('test/resources/black_white.png') + (upper_part, lower_part) = im.split(1) + upper_part = EscposImage(upper_part) + lower_part = EscposImage(lower_part) + assert(upper_part.width == lower_part.width == 2) + assert(upper_part.height == lower_part.height == 1) + assert(upper_part.to_raster_format() == b'\xc0') + assert(lower_part.to_raster_format() == b'\x00') + + def _load_and_check_img(filename, width_expected, height_expected, raster_format_expected, column_format_expected): """ Load an image, and test whether raster & column formatted output, sizes, etc match expectations.