diff --git a/setup.cfg b/setup.cfg new file mode 100644 index 0000000..9b67573 --- /dev/null +++ b/setup.cfg @@ -0,0 +1,3 @@ +[nosetests] +verbosity=3 +with-doctest=1 diff --git a/test/50x50.png b/test/50x50.png new file mode 100644 index 0000000..67b483b Binary files /dev/null and b/test/50x50.png differ diff --git a/test/Dies ist ein Test.LF.txt b/test/Dies ist ein Test.LF.txt new file mode 100644 index 0000000..d7e5cff --- /dev/null +++ b/test/Dies ist ein Test.LF.txt @@ -0,0 +1 @@ +Dies ist ein Test. diff --git a/test/test_function_image.py b/test/test_function_image.py new file mode 100644 index 0000000..135da9e --- /dev/null +++ b/test/test_function_image.py @@ -0,0 +1,38 @@ +#!/usr/bin/python +"""tests for the image printing function + +:author: `Patrick Kanzler `_ +:organization: `python-escpos `_ +:copyright: Copyright (c) 2016 `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 + +from nose.tools import with_setup + +import escpos.printer as printer +import os + +devfile = 'testfile' + +def setup_testfile(): + """create a testfile as devfile""" + fhandle = open(devfile, 'a') + try: + os.utime(devfile, None) + finally: + fhandle.close() + +def teardown_testfile(): + """destroy testfile again""" + os.remove(devfile) + +@with_setup(setup_testfile, teardown_testfile) +def test_function_image_with_50x50_png(): + """test the image function with 50x50.png (grayscale png)""" + instance = printer.File(devfile=devfile) + instance.image("test/50x50.png") diff --git a/test/test_function_text.py b/test/test_function_text.py new file mode 100644 index 0000000..2ad7bd1 --- /dev/null +++ b/test/test_function_text.py @@ -0,0 +1,42 @@ +#!/usr/bin/python +"""tests for the text printing function + +:author: `Patrick Kanzler `_ +:organization: `python-escpos `_ +:copyright: Copyright (c) 2016 `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 + +from nose.tools import with_setup + +import escpos.printer as printer +import os + +import filecmp + +devfile = 'testfile' + +def setup_testfile(): + """create a testfile as devfile""" + fhandle = open(devfile, 'a') + try: + os.utime(devfile, None) + finally: + fhandle.close() + +def teardown_testfile(): + """destroy testfile again""" + os.remove(devfile) + +@with_setup(setup_testfile, teardown_testfile) +def test_function_text_dies_ist_ein_test_lf(): + """test the text printing function with simple string and compare output""" + instance = printer.File(devfile=devfile) + instance.text('Dies ist ein Test.\n') + instance.flush() + assert(filecmp.cmp('test/Dies ist ein Test.LF.txt', devfile)) diff --git a/test/test_load_module.py b/test/test_load_module.py index 9603cf1..0cfcce9 100644 --- a/test/test_load_module.py +++ b/test/test_load_module.py @@ -7,6 +7,11 @@ :license: GNU GPL v3 """ +from __future__ import absolute_import +from __future__ import division +from __future__ import print_function +from __future__ import unicode_literals + from nose.tools import with_setup import escpos.printer as printer