From 41333cd6e1a2472e47a4c4f4f37d70e2585c2cfc Mon Sep 17 00:00:00 2001 From: Florian Bruhin Date: Thu, 23 Jul 2015 16:58:21 +0200 Subject: [PATCH] configtypes: Add some additional tests. --- tests/config/test_configtypes.py | 42 +++++++++++++++++++------------- 1 file changed, 25 insertions(+), 17 deletions(-) diff --git a/tests/config/test_configtypes.py b/tests/config/test_configtypes.py index 6a290774e..80d9cec6c 100644 --- a/tests/config/test_configtypes.py +++ b/tests/config/test_configtypes.py @@ -804,20 +804,14 @@ class TestFont: FontDesc(QFont.StyleNormal, QFont.Bold, 10, None, 'Foobar Neue'), 'bold italic 10pt "Foobar Neue"': FontDesc(QFont.StyleItalic, QFont.Bold, 10, None, 'Foobar Neue'), + 'normal 300 10pt "Foobar Neue"': + FontDesc(QFont.StyleNormal, 37.5, 10, None, 'Foobar Neue'), + 'normal 800 10pt "Foobar Neue"': + FontDesc(QFont.StyleNormal, 99, 10, None, 'Foobar Neue'), } - INVALID = [ - 'green "Foobar Neue"', - 'italic green "Foobar Neue"', - 'bold bold "Foobar Neue"', - 'bold italic "Foobar Neue"', - '10pt 20px "Foobar Neue"', - 'bold', - 'italic', - 'green', - '10pt', - '10pt ""', - ] + font_xfail = pytest.mark.xfail(reason='FIXME: #103') + @pytest.fixture(params=[configtypes.Font, configtypes.QtFont]) def klass(self, request): @@ -835,8 +829,19 @@ class TestFont: def test_validate_valid(self, klass, val): klass(none_ok=True).validate(val) - @pytest.mark.parametrize('val', INVALID) - @pytest.mark.xfail(reason='FIXME: #103') + @pytest.mark.parametrize('val', [ + font_xfail('green "Foobar Neue"'), + font_xfail('italic green "Foobar Neue"'), + font_xfail('bold bold "Foobar Neue"'), + font_xfail('bold italic "Foobar Neue"'), + font_xfail('10pt 20px "Foobar Neue"'), + font_xfail('bold'), + font_xfail('italic'), + font_xfail('green'), + font_xfail('10pt'), + font_xfail('10pt ""'), + '%', + ]) def test_validate_invalid(self, klass, val): with pytest.raises(configexc.ValidationError): klass().validate(val) @@ -895,6 +900,7 @@ class TestFontFamily: 'normal bold 10pt "Foobar Neue"', 'bold italic 10pt "Foobar Neue"', '', # with none_ok=False + '%', ] @pytest.fixture @@ -1229,6 +1235,7 @@ class TestShellCommand: ({}, ''), ({'placeholder': '{}'}, 'foo{} bar'), ({'placeholder': '{}'}, 'foo bar'), + ({}, 'foo"'), # not splittable with shlex ]) def test_validate_invalid(self, klass, kwargs, val): with pytest.raises(configexc.ValidationError): @@ -1318,13 +1325,14 @@ class TestSearchEngineName: def klass(self): return configtypes.SearchEngineName + @pytest.mark.parametrize('val', ['', 'foobar']) + def test_validate_valid(self, klass, val): + klass(none_ok=True).validate(val) + def test_validate_empty(self, klass): with pytest.raises(configexc.ValidationError): klass().validate('') - def test_validate_empty_none_ok(self, klass): - klass(none_ok=True).validate('') - @pytest.mark.parametrize('val, expected', [('', None), ('foobar', 'foobar')]) def test_transform(self, klass, val, expected):