python-escpos/test/test_profile.py
Patrick Kanzler fbabd8ed88
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
2023-08-15 01:03:36 +02:00

38 lines
1016 B
Python

import pytest
from escpos.capabilities import BARCODE_B, NotSupported, Profile, get_profile
@pytest.fixture
def profile():
return get_profile("default")
class TestBaseProfile:
"""Test the `BaseProfile` class."""
def test_get_font(self, profile):
with pytest.raises(NotSupported):
assert profile.get_font("3")
assert profile.get_font(1) == 1
assert profile.get_font("a") == 0
def test_supports(self, profile):
assert not profile.supports("asdf asdf")
assert profile.supports(BARCODE_B)
def test_get_columns(self, profile):
assert profile.get_columns("a") > 5
with pytest.raises(NotSupported):
assert profile.get_columns("asdfasdf")
class TestCustomProfile:
"""Test custom profile options with the `Profile` class."""
def test_columns(self):
assert Profile(columns=10).get_columns("sdfasdf") == 10
def test_features(self):
assert Profile(features={"foo": True}).supports("foo")