diff --git a/.coveragerc b/.coveragerc new file mode 100644 index 0000000..398ff08 --- /dev/null +++ b/.coveragerc @@ -0,0 +1,2 @@ +[run] +branch = True diff --git a/src/escpos/capabilities.py b/src/escpos/capabilities.py index 1330964..e569ccc 100644 --- a/src/escpos/capabilities.py +++ b/src/escpos/capabilities.py @@ -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): diff --git a/test/test_function_barcode.py b/test/test_function_barcode.py index c6ec958..2edd712 100644 --- a/test/test_function_barcode.py +++ b/test/test_function_barcode.py @@ -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): diff --git a/test/test_profile.py b/test/test_profile.py index c9418d5..d75c88c 100644 --- a/test/test_profile.py +++ b/test/test_profile.py @@ -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