From 5bf26367538f9ffb572659b3c49582aa29dbff2a Mon Sep 17 00:00:00 2001 From: Patrick Kanzler Date: Mon, 22 May 2017 00:44:22 +0200 Subject: [PATCH] rewrite to Dummy() --- test/test_function_panel_button.py | 33 ++++-------------------------- test/test_load_module.py | 22 +------------------- 2 files changed, 5 insertions(+), 50 deletions(-) diff --git a/test/test_function_panel_button.py b/test/test_function_panel_button.py index 1006e5b..cdf840b 100644 --- a/test/test_function_panel_button.py +++ b/test/test_function_panel_button.py @@ -12,43 +12,18 @@ 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_panel_button_on(): """test the panel button function (enabling) by comparing output""" - instance = printer.File(devfile=devfile) + instance = printer.Dummy() instance.panel_buttons() - instance.flush() - with open(devfile, "rb") as f: - assert(f.read() == b'\x1B\x63\x35\x00') + assert(instance.output == b'\x1B\x63\x35\x00') -@with_setup(setup_testfile, teardown_testfile) def test_function_panel_button_off(): """test the panel button function (disabling) by comparing output""" - instance = printer.File(devfile=devfile) + instance = printer.Dummy() instance.panel_buttons(False) - instance.flush() - with open(devfile, "rb") as f: - assert(f.read() == b'\x1B\x63\x35\x01') + assert(instance.output == b'\x1B\x63\x35\x01') diff --git a/test/test_load_module.py b/test/test_load_module.py index aeffc5b..efae1b3 100644 --- a/test/test_load_module.py +++ b/test/test_load_module.py @@ -12,30 +12,10 @@ 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_instantiation(): """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')