diff --git a/src/escpos/capabilities.py b/src/escpos/capabilities.py index 6e375bc..9ae0e79 100644 --- a/src/escpos/capabilities.py +++ b/src/escpos/capabilities.py @@ -100,7 +100,7 @@ class Profile(get_profile_class('default')): def get_columns(self, font): if self.columns is not None: - return columns + return self.columns return super(Profile, self).get_columns(font) diff --git a/test/test_profile.py b/test/test_profile.py new file mode 100644 index 0000000..c9418d5 --- /dev/null +++ b/test/test_profile.py @@ -0,0 +1,34 @@ +import pytest +from escpos.capabilities import get_profile, NotSupported, BARCODE_B, Profile + + +@pytest.fixture +def profile(): + return get_profile('default') + + +class TestBaseProfile: + + 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: + + def test_columns(self): + assert Profile(columns=10).get_columns('sdfasdf') == 10 + + def test_features(self): + assert Profile(features={'foo': True}).supports('foo') \ No newline at end of file