2016-02-10 18:32:00 +00:00
|
|
|
#!/usr/bin/python
|
|
|
|
"""very basic test cases that load the classes
|
|
|
|
|
2016-02-11 17:37:13 +00:00
|
|
|
:author: `Patrick Kanzler <patrick.kanzler@fablab.fau.de>`_
|
|
|
|
:organization: `python-escpos <https://github.com/python-escpos>`_
|
2016-02-10 18:32:00 +00:00
|
|
|
:copyright: Copyright (c) 2016 `python-escpos <https://github.com/python-escpos>`_
|
2017-01-29 23:39:43 +00:00
|
|
|
:license: MIT
|
2016-02-10 18:32:00 +00:00
|
|
|
"""
|
|
|
|
|
2016-03-02 22:16:58 +00:00
|
|
|
from __future__ import absolute_import
|
|
|
|
from __future__ import division
|
|
|
|
from __future__ import print_function
|
|
|
|
from __future__ import unicode_literals
|
|
|
|
|
2016-02-10 18:32:00 +00:00
|
|
|
from nose.tools import with_setup
|
|
|
|
|
|
|
|
import escpos.printer as printer
|
|
|
|
import os
|
|
|
|
|
2016-02-11 17:37:13 +00:00
|
|
|
devfile = 'testfile'
|
|
|
|
|
2016-04-02 13:29:51 +00:00
|
|
|
|
2016-02-10 18:32:00 +00:00
|
|
|
def setup_testfile():
|
|
|
|
"""create a testfile as devfile"""
|
2016-02-11 17:37:13 +00:00
|
|
|
fhandle = open(devfile, 'a')
|
2016-02-10 18:32:00 +00:00
|
|
|
try:
|
2016-02-11 17:37:13 +00:00
|
|
|
os.utime(devfile, None)
|
2016-02-10 18:32:00 +00:00
|
|
|
finally:
|
|
|
|
fhandle.close()
|
|
|
|
|
2016-04-02 13:29:51 +00:00
|
|
|
|
2016-02-10 18:32:00 +00:00
|
|
|
def teardown_testfile():
|
|
|
|
"""destroy testfile again"""
|
2016-02-11 17:37:13 +00:00
|
|
|
os.remove(devfile)
|
2016-02-10 18:32:00 +00:00
|
|
|
|
2016-04-02 13:29:51 +00:00
|
|
|
|
2016-02-10 18:32:00 +00:00
|
|
|
@with_setup(setup_testfile, teardown_testfile)
|
|
|
|
def test_instantiation():
|
|
|
|
"""test the instantiation of a escpos-printer class and basic printing"""
|
2016-02-11 17:37:13 +00:00
|
|
|
instance = printer.File(devfile=devfile)
|
2016-02-10 18:32:00 +00:00
|
|
|
instance.text('This is a test\n')
|