Merge branch 'capabilities' into text-encoding

This commit is contained in:
Michael Elsdörfer 2016-08-30 18:02:40 +02:00
commit c3e3ec5808
4 changed files with 14 additions and 1 deletions

2
.coveragerc Normal file
View File

@ -0,0 +1,2 @@
[run]
branch = True

View File

@ -13,6 +13,9 @@ PROFILES = CAPABILITIES['profiles']
class NotSupported(Exception):
"""Raised if a requested feature is not suppored by the
printer profile.
"""
pass
@ -38,7 +41,7 @@ class BaseProfile(object):
font = {'a': 0, 'b': 1}.get(font, font)
if not six.text_type(font) in self.fonts:
raise NotSupported(
'"%s" is not a valid font in the current profile' % font)
'"{}" is not a valid font in the current profile'.format(font))
return font
def get_columns(self, font):

View File

@ -16,6 +16,8 @@ import pytest
b'\x1ba\x01\x1dh@\x1dw\x03\x1df\x00\x1dH\x02\x1dk\x024006381333931\x00')
])
def test_barcode(bctype, data, expected):
"""should generate different barcode types correctly.
"""
instance = printer.Dummy()
instance.barcode(data, bctype)
assert instance.output == expected
@ -26,6 +28,8 @@ def test_barcode(bctype, data, expected):
('CODE128', False),
])
def test_lacks_support(bctype, supports_b):
"""should raise an error if the barcode type is not supported.
"""
profile = Profile(features={BARCODE_B: supports_b})
instance = printer.Dummy(profile=profile)
with pytest.raises(BarcodeTypeError):

View File

@ -8,6 +8,8 @@ def profile():
class TestBaseProfile:
"""Test the `BaseProfile` class.
"""
def test_get_font(self, profile):
with pytest.raises(NotSupported):
@ -26,6 +28,8 @@ class TestBaseProfile:
class TestCustomProfile:
"""Test custom profile options with the `Profile` class.
"""
def test_columns(self):
assert Profile(columns=10).get_columns('sdfasdf') == 10