From 8756d9e64488ec034885e13c7e6f747a2921bbb2 Mon Sep 17 00:00:00 2001 From: Florian Bruhin Date: Thu, 7 Aug 2014 07:56:47 +0200 Subject: [PATCH] test_conftypes: Test float point size correctly. --- qutebrowser/test/config/test_conftypes.py | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/qutebrowser/test/config/test_conftypes.py b/qutebrowser/test/config/test_conftypes.py index 9ba62ffcd..7e8ebdab8 100644 --- a/qutebrowser/test/config/test_conftypes.py +++ b/qutebrowser/test/config/test_conftypes.py @@ -1072,8 +1072,6 @@ class FontTests(unittest.TestCase): FontDesc(QFont.StyleNormal, QFont.Normal, 10, None, 'Foobar Neue'), '10PT "Foobar Neue"': FontDesc(QFont.StyleNormal, QFont.Normal, 10, None, 'Foobar Neue'), - '10.5pt "Foobar Neue"': - FontDesc(QFont.StyleNormal, QFont.Normal, 10.5, None, 'Foobar Neue'), '10px "Foobar Neue"': FontDesc(QFont.StyleNormal, QFont.Normal, None, 10, 'Foobar Neue'), '10PX "Foobar Neue"': @@ -1141,7 +1139,6 @@ class FontTests(unittest.TestCase): with self.assertRaises(conftypes.ValidationError, msg=val): self.t2.validate(val) - # FIXME def test_transform(self): """Test transform.""" for string, desc in self.TESTS.items(): @@ -1152,6 +1149,19 @@ class FontTests(unittest.TestCase): self.assertEqual(Font(self.t2.transform(string)), Font.fromdesc(desc), string) + def test_transform_float(self): + """Test QtFont's transform with a float as point size. + + We can't test the point size for equality as Qt seems to do some + rounding as appropriate. + """ + value = Font(self.t2.transform('10.5pt "Foobar Neue"')) + self.assertEqual(value.family(), 'Foobar Neue') + self.assertEqual(value.weight(), QFont.Normal) + self.assertEqual(value.style(), QFont.StyleNormal) + self.assertGreaterEqual(value.pointSize(), 10) + self.assertLessEqual(value.pointSize(), 11) + def test_transform_empty(self): """Test transform with an empty value.""" self.assertIsNone(self.t.transform(''))