rewrite to Dummy()
This commit is contained in:
parent
1f427953a8
commit
5bf2636753
|
@ -12,43 +12,18 @@ from __future__ import division
|
||||||
from __future__ import print_function
|
from __future__ import print_function
|
||||||
from __future__ import unicode_literals
|
from __future__ import unicode_literals
|
||||||
|
|
||||||
from nose.tools import with_setup
|
|
||||||
|
|
||||||
import escpos.printer as printer
|
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_panel_button_on():
|
def test_function_panel_button_on():
|
||||||
"""test the panel button function (enabling) by comparing output"""
|
"""test the panel button function (enabling) by comparing output"""
|
||||||
instance = printer.File(devfile=devfile)
|
instance = printer.Dummy()
|
||||||
instance.panel_buttons()
|
instance.panel_buttons()
|
||||||
instance.flush()
|
assert(instance.output == b'\x1B\x63\x35\x00')
|
||||||
with open(devfile, "rb") as f:
|
|
||||||
assert(f.read() == b'\x1B\x63\x35\x00')
|
|
||||||
|
|
||||||
|
|
||||||
@with_setup(setup_testfile, teardown_testfile)
|
|
||||||
def test_function_panel_button_off():
|
def test_function_panel_button_off():
|
||||||
"""test the panel button function (disabling) by comparing output"""
|
"""test the panel button function (disabling) by comparing output"""
|
||||||
instance = printer.File(devfile=devfile)
|
instance = printer.Dummy()
|
||||||
instance.panel_buttons(False)
|
instance.panel_buttons(False)
|
||||||
instance.flush()
|
assert(instance.output == b'\x1B\x63\x35\x01')
|
||||||
with open(devfile, "rb") as f:
|
|
||||||
assert(f.read() == b'\x1B\x63\x35\x01')
|
|
||||||
|
|
|
@ -12,30 +12,10 @@ from __future__ import division
|
||||||
from __future__ import print_function
|
from __future__ import print_function
|
||||||
from __future__ import unicode_literals
|
from __future__ import unicode_literals
|
||||||
|
|
||||||
from nose.tools import with_setup
|
|
||||||
|
|
||||||
import escpos.printer as printer
|
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_instantiation():
|
def test_instantiation():
|
||||||
"""test the instantiation of a escpos-printer class and basic printing"""
|
"""test the instantiation of a escpos-printer class and basic printing"""
|
||||||
instance = printer.File(devfile=devfile)
|
instance = printer.Dummy()
|
||||||
instance.text('This is a test\n')
|
instance.text('This is a test\n')
|
||||||
|
|
Loading…
Reference in New Issue