mirror of
https://github.com/python-escpos/python-escpos
synced 2025-08-24 09:03:34 +00:00
Drop Py37, improve typing and docstrings (#544)
Drops Py3.7, improves typing and adds a mypy config, improves the docstrings and isorts the imports. * configure isort * sort with isort * add github action * enable flake8-docstrings * fix docstrings * add mypy env * no implicit optional * add type for raw * add some type hints
This commit is contained in:
@@ -1,4 +1,5 @@
|
||||
import pytest
|
||||
|
||||
from escpos.printer import Dummy
|
||||
|
||||
|
||||
|
@@ -1,16 +1,18 @@
|
||||
#!/usr/bin/python
|
||||
"""verifies that the metaclass abc is properly used by ESC/POS
|
||||
|
||||
:author: `Patrick Kanzler <patrick.kanzler@fablab.fau.de>`_
|
||||
:author: `Patrick Kanzler <dev@pkanzler.de>`_
|
||||
:organization: `python-escpos <https://github.com/python-escpos>`_
|
||||
:copyright: Copyright (c) 2016 Patrick Kanzler
|
||||
:license: MIT
|
||||
"""
|
||||
|
||||
import pytest
|
||||
import escpos.escpos as escpos
|
||||
from abc import ABCMeta
|
||||
|
||||
import pytest
|
||||
|
||||
import escpos.escpos as escpos
|
||||
|
||||
|
||||
def test_abstract_base_class_raises():
|
||||
"""test whether the abstract base class raises an exception for ESC/POS"""
|
||||
|
@@ -4,10 +4,12 @@
|
||||
|
||||
|
||||
import os
|
||||
import shutil
|
||||
import tempfile
|
||||
|
||||
import pytest
|
||||
from scripttest import TestFileEnvironment as TFE
|
||||
import tempfile
|
||||
import shutil
|
||||
|
||||
import escpos
|
||||
|
||||
TEST_DIR = tempfile.mkdtemp() + "/cli-test"
|
||||
|
@@ -1,10 +1,11 @@
|
||||
#!/usr/bin/python
|
||||
|
||||
import escpos.printer as printer
|
||||
from escpos.capabilities import Profile, BARCODE_B
|
||||
from escpos.exceptions import BarcodeTypeError, BarcodeCodeError
|
||||
import pytest
|
||||
|
||||
import escpos.printer as printer
|
||||
from escpos.capabilities import BARCODE_B, Profile
|
||||
from escpos.exceptions import BarcodeCodeError, BarcodeTypeError
|
||||
|
||||
|
||||
@pytest.mark.parametrize(
|
||||
"bctype,data,expected",
|
||||
|
@@ -1,5 +1,5 @@
|
||||
import six
|
||||
import pytest
|
||||
import six
|
||||
|
||||
from escpos import printer
|
||||
from escpos.constants import BUZZER
|
||||
|
@@ -1,8 +1,9 @@
|
||||
#!/usr/bin/python
|
||||
|
||||
import pytest
|
||||
|
||||
import escpos.printer as printer
|
||||
from escpos.exceptions import CashDrawerError
|
||||
import pytest
|
||||
|
||||
|
||||
def test_raise_CashDrawerError():
|
||||
|
@@ -2,9 +2,10 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
|
||||
|
||||
import escpos.printer as printer
|
||||
import pytest
|
||||
|
||||
import escpos.printer as printer
|
||||
|
||||
|
||||
@pytest.mark.parametrize(
|
||||
"bctype,data",
|
||||
|
@@ -9,7 +9,6 @@
|
||||
|
||||
|
||||
import pytest
|
||||
|
||||
from PIL import Image
|
||||
|
||||
import escpos.printer as printer
|
||||
|
@@ -1,7 +1,7 @@
|
||||
#!/usr/bin/python
|
||||
"""tests for line display
|
||||
|
||||
:author: `Patrick Kanzler <patrick.kanzler@fablab.fau.de>`_
|
||||
:author: `Patrick Kanzler <dev@pkanzler.de>`_
|
||||
:organization: `python-escpos <https://github.com/python-escpos>`_
|
||||
:copyright: Copyright (c) 2017 `python-escpos <https://github.com/python-escpos>`_
|
||||
:license: MIT
|
||||
|
@@ -1,7 +1,7 @@
|
||||
#!/usr/bin/python
|
||||
"""tests for panel button function
|
||||
|
||||
:author: `Patrick Kanzler <patrick.kanzler@fablab.fau.de>`_
|
||||
:author: `Patrick Kanzler <dev@pkanzler.de>`_
|
||||
:organization: `python-escpos <https://github.com/python-escpos>`_
|
||||
:copyright: Copyright (c) 2016 `python-escpos <https://github.com/python-escpos>`_
|
||||
:license: MIT
|
||||
|
@@ -2,18 +2,18 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
"""tests for the non-native part of qr()
|
||||
|
||||
:author: `Patrick Kanzler <patrick.kanzler@fablab.fau.de>`_
|
||||
:author: `Patrick Kanzler <dev@pkanzler.de>`_
|
||||
:organization: `python-escpos <https://github.com/python-escpos>`_
|
||||
:copyright: Copyright (c) 2016 `python-escpos <https://github.com/python-escpos>`_
|
||||
:license: MIT
|
||||
"""
|
||||
|
||||
|
||||
import pytest
|
||||
import mock
|
||||
import pytest
|
||||
from PIL import Image
|
||||
|
||||
from escpos.printer import Dummy
|
||||
from PIL import Image
|
||||
|
||||
|
||||
@mock.patch("escpos.printer.Dummy.image", spec=Dummy)
|
||||
|
@@ -1,9 +1,7 @@
|
||||
import six
|
||||
|
||||
import escpos.printer as printer
|
||||
from escpos.constants import TXT_NORMAL, TXT_STYLE, SET_FONT
|
||||
from escpos.constants import TXT_SIZE
|
||||
|
||||
from escpos.constants import SET_FONT, TXT_NORMAL, TXT_SIZE, TXT_STYLE
|
||||
|
||||
# Default test, please copy and paste this block to test set method calls
|
||||
|
||||
|
@@ -1,9 +1,10 @@
|
||||
#!/usr/bin/python
|
||||
|
||||
import escpos.printer as printer
|
||||
import barcode.errors
|
||||
import pytest
|
||||
|
||||
import escpos.printer as printer
|
||||
|
||||
|
||||
@pytest.fixture
|
||||
def instance():
|
||||
|
@@ -1,17 +1,18 @@
|
||||
#!/usr/bin/python
|
||||
"""tests for the text printing function
|
||||
|
||||
:author: `Patrick Kanzler <patrick.kanzler@fablab.fau.de>`_
|
||||
:author: `Patrick Kanzler <dev@pkanzler.de>`_
|
||||
:organization: `python-escpos <https://github.com/python-escpos>`_
|
||||
:copyright: Copyright (c) 2016 `python-escpos <https://github.com/python-escpos>`_
|
||||
:license: MIT
|
||||
"""
|
||||
|
||||
|
||||
import pytest
|
||||
import mock
|
||||
from hypothesis import given, assume
|
||||
import hypothesis.strategies as st
|
||||
import mock
|
||||
import pytest
|
||||
from hypothesis import assume, given
|
||||
|
||||
from escpos.printer import Dummy
|
||||
|
||||
|
||||
|
@@ -1,4 +1,5 @@
|
||||
import pytest
|
||||
|
||||
from escpos.printer import Dummy
|
||||
|
||||
|
||||
|
@@ -1,7 +1,7 @@
|
||||
#!/usr/bin/python
|
||||
"""very basic test cases that load the classes
|
||||
|
||||
:author: `Patrick Kanzler <patrick.kanzler@fablab.fau.de>`_
|
||||
:author: `Patrick Kanzler <dev@pkanzler.de>`_
|
||||
:organization: `python-escpos <https://github.com/python-escpos>`_
|
||||
:copyright: Copyright (c) 2016 `python-escpos <https://github.com/python-escpos>`_
|
||||
:license: MIT
|
||||
|
@@ -2,19 +2,20 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
"""tests for the magic encode module
|
||||
|
||||
:author: `Patrick Kanzler <patrick.kanzler@fablab.fau.de>`_
|
||||
:author: `Patrick Kanzler <dev@pkanzler.de>`_
|
||||
:organization: `python-escpos <https://github.com/python-escpos>`_
|
||||
:copyright: Copyright (c) 2016 `python-escpos <https://github.com/python-escpos>`_
|
||||
:license: MIT
|
||||
"""
|
||||
|
||||
|
||||
import pytest
|
||||
from hypothesis import given, example
|
||||
import hypothesis.strategies as st
|
||||
from escpos.magicencode import MagicEncode, Encoder
|
||||
from escpos.katakana import encode_katakana
|
||||
import pytest
|
||||
from hypothesis import example, given
|
||||
|
||||
from escpos.exceptions import CharCodeError, Error
|
||||
from escpos.katakana import encode_katakana
|
||||
from escpos.magicencode import Encoder, MagicEncode
|
||||
|
||||
|
||||
class TestEncoder:
|
||||
|
@@ -2,16 +2,15 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
"""tests for the File printer
|
||||
|
||||
:author: `Patrick Kanzler <patrick.kanzler@fablab.fau.de>`_
|
||||
:author: `Patrick Kanzler <dev@pkanzler.de>`_
|
||||
:organization: `python-escpos <https://github.com/python-escpos>`_
|
||||
:copyright: Copyright (c) 2016 `python-escpos <https://github.com/python-escpos>`_
|
||||
:license: MIT
|
||||
"""
|
||||
|
||||
|
||||
import six
|
||||
|
||||
import pytest
|
||||
import six
|
||||
from hypothesis import given, settings
|
||||
from hypothesis.strategies import text
|
||||
|
||||
|
@@ -1,10 +1,12 @@
|
||||
#!/usr/bin/python
|
||||
|
||||
import escpos.printer as printer
|
||||
import pytest
|
||||
import mock
|
||||
import socket
|
||||
|
||||
import mock
|
||||
import pytest
|
||||
|
||||
import escpos.printer as printer
|
||||
|
||||
|
||||
@pytest.fixture
|
||||
def instance():
|
||||
|
@@ -1,5 +1,6 @@
|
||||
import pytest
|
||||
from escpos.capabilities import get_profile, NotSupported, BARCODE_B, Profile
|
||||
|
||||
from escpos.capabilities import BARCODE_B, NotSupported, Profile, get_profile
|
||||
|
||||
|
||||
@pytest.fixture
|
||||
|
@@ -1,7 +1,7 @@
|
||||
#!/usr/bin/python
|
||||
"""test the raising of errors with the error module
|
||||
|
||||
:author: `Patrick Kanzler <patrick.kanzler@fablab.fau.de>`_
|
||||
:author: `Patrick Kanzler <dev@pkanzler.de>`_
|
||||
:organization: `python-escpos <https://github.com/python-escpos>`_
|
||||
:copyright: Copyright (c) 2017 `python-escpos <https://github.com/python-escpos>`_
|
||||
:license: MIT
|
||||
@@ -9,6 +9,7 @@
|
||||
|
||||
|
||||
import pytest
|
||||
|
||||
import escpos
|
||||
import escpos.exceptions
|
||||
|
||||
|
@@ -1,20 +1,21 @@
|
||||
#!/usr/bin/python
|
||||
"""test the facility which enables usage of the with-statement
|
||||
|
||||
:author: `Patrick Kanzler <patrick.kanzler@fablab.fau.de>`_
|
||||
:author: `Patrick Kanzler <dev@pkanzler.de>`_
|
||||
:organization: `python-escpos <https://github.com/python-escpos>`_
|
||||
:copyright: Copyright (c) 2016 `python-escpos <https://github.com/python-escpos>`_
|
||||
:license: MIT
|
||||
"""
|
||||
|
||||
|
||||
import escpos.printer as printer
|
||||
import escpos.escpos as escpos
|
||||
import escpos.printer as printer
|
||||
|
||||
|
||||
def test_with_statement():
|
||||
"""Use with statement"""
|
||||
"""Use with statement
|
||||
|
||||
.. todo:: Extend these tests as they don't really do anything at the moment"""
|
||||
dummy_printer = printer.Dummy()
|
||||
with escpos.EscposIO(dummy_printer) as p:
|
||||
p.writelines("Some text.\n")
|
||||
# TODO extend these tests as they don't really do anything at the moment
|
||||
|
Reference in New Issue
Block a user