From c850a726cbcf8b4c6d6a09931e3927bf04cb04ae Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Michael=20Elsd=C3=B6rfer?= Date: Tue, 30 Aug 2016 17:55:58 +0200 Subject: [PATCH] Fix docstring warnings from QuantifedCode. --- src/escpos/capabilities.py | 5 ++++- test/test_function_barcode.py | 4 ++++ test/test_profile.py | 4 ++++ 3 files changed, 12 insertions(+), 1 deletion(-) diff --git a/src/escpos/capabilities.py b/src/escpos/capabilities.py index 3dd5c32..15416ed 100644 --- a/src/escpos/capabilities.py +++ b/src/escpos/capabilities.py @@ -12,6 +12,9 @@ ENCODINGS = CAPABILITIES['encodings'] class NotSupported(Exception): + """Raised if a requested feature is not suppored by the + printer profile. + """ pass @@ -37,7 +40,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