python-escpos/test/test_function_text.py
Patrick Kanzler 0cfedb5706 add automatic codepage-changing
This code is adapted from the works by Frédéric Van der Essen in
pyxmlescpos.
I had to adapt the code completely in order to make it compatible with
modern unicode-handling

Further changes:
* improve text unittests in CLI and MagicEncode with hypothesis
* add feature force_encoding in order to enable old behaviour
* disable cli_text_test (for now)
* fix charcode(): it does now cooperate with the new structure
* remove redundant variable codepage from class Escpos
2016-08-02 04:42:21 +02:00

28 lines
870 B
Python

#!/usr/bin/python
"""tests for the text printing function
:author: `Patrick Kanzler <patrick.kanzler@fablab.fau.de>`_
: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 hypothesis import given
import hypothesis.strategies as st
import escpos.printer as printer
@given(text=st.text())
def test_function_text_dies_ist_ein_test_lf(text):
"""test the text printing function with simple string and compare output"""
instance = printer.Dummy()
instance.magic.encode_text = mock.Mock()
instance.text(text)
instance.magic.encode_text.assert_called_with(txt=text)