forked from python-escpos/python-escpos
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request python-escpos#169 from python-escpos/development
v2.2.0
- Loading branch information
Showing
6 changed files
with
123 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
#!/usr/bin/python | ||
#!/usr/bin/env python | ||
|
||
import os | ||
import sys | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
#!/usr/bin/python | ||
# -*- coding: utf-8 -*- | ||
"""tests for the non-native part of qr() | ||
:author: `Patrick Kanzler <[email protected]>`_ | ||
:organization: `python-escpos <https://github.com/python-escpos>`_ | ||
:copyright: Copyright (c) 2016 `python-escpos <https://github.com/python-escpos>`_ | ||
:license: GNU GPL v3 | ||
""" | ||
|
||
from __future__ import absolute_import | ||
from __future__ import division | ||
from __future__ import print_function | ||
from __future__ import unicode_literals | ||
|
||
import mock | ||
|
||
from escpos.printer import Dummy | ||
from PIL import Image | ||
|
||
|
||
@mock.patch('escpos.printer.Dummy.image', spec=Dummy) | ||
def test_type_of_object_passed_to_image_function(img_function): | ||
""" | ||
Test the type of object that is passed to the image function during non-native qr-printing. | ||
The type should be PIL.Image | ||
""" | ||
d = Dummy() | ||
d.qr("LoremIpsum") | ||
args, kwargs = img_function.call_args | ||
assert isinstance(args[0], Image.Image) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
from nose.tools import assert_raises | ||
from escpos.printer import Dummy | ||
|
||
|
||
def test_line_spacing_code_gen(): | ||
printer = Dummy() | ||
printer.line_spacing(10) | ||
assert printer.output == b'\x1b3\n' | ||
|
||
|
||
def test_line_spacing_rest(): | ||
printer = Dummy() | ||
printer.line_spacing() | ||
assert printer.output == b'\x1b2' | ||
|
||
|
||
def test_line_spacing_error_handling(): | ||
printer = Dummy() | ||
with assert_raises(ValueError): | ||
printer.line_spacing(99, divisor=44) | ||
with assert_raises(ValueError): | ||
printer.line_spacing(divisor=80, spacing=86) | ||
with assert_raises(ValueError): | ||
printer.line_spacing(divisor=360, spacing=256) | ||
with assert_raises(ValueError): | ||
printer.line_spacing(divisor=180, spacing=256) |