def test_style(self): self.assertFont(font('italic 12pt Comic Sans'), 'Comic Sans', 12, ITALIC, NORMAL, NORMAL) self.assertFont(font('oblique 12pt Comic Sans'), 'Comic Sans', 12, OBLIQUE, NORMAL, NORMAL) with self.assertRaises(ValueError): font('wiggly small-caps bold 12pt Comic Sans')
def test_normal(self): self.assertFont(font('normal 12pt Comic Sans'), 'Comic Sans', 12, NORMAL, NORMAL, NORMAL) self.assertFont(font('italic normal 12pt Comic Sans'), 'Comic Sans', 12, ITALIC, NORMAL, NORMAL) self.assertFont(font('italic small-caps normal 12pt Comic Sans'), 'Comic Sans', 12, ITALIC, SMALL_CAPS, NORMAL)
def test_font_sizes(self): self.assertFont(font('12pt Comic Sans'), 'Comic Sans', 12, NORMAL, NORMAL, NORMAL) self.assertFont(font('12 pt Comic Sans'), 'Comic Sans', 12, NORMAL, NORMAL, NORMAL) self.assertFont(font('12 Comic Sans'), 'Comic Sans', 12, NORMAL, NORMAL, NORMAL) with self.assertRaises(ValueError): font('12quatloo Comic Sans')
def test_font_instance(self): f = Font('Comic Sans', 12) parsed = font(f) self.assertEqual(f, parsed) self.assertIs(f, parsed)
def test_duplicates(self): with self.assertRaises(ValueError): font('oblique italic 12pt Comic Sans') with self.assertRaises(ValueError): font('italic small-caps oblique 12pt Comic Sans') with self.assertRaises(ValueError): font('italic small-caps bold small-caps 12pt Comic Sans') with self.assertRaises(ValueError): font('bold bold 12pt Comic Sans')
def test_successful_combinations(self): self.assertFont(font('12pt Comic Sans'), 'Comic Sans', 12, NORMAL, NORMAL, NORMAL) self.assertFont(font('italic 12pt Comic Sans'), 'Comic Sans', 12, ITALIC, NORMAL, NORMAL) self.assertFont(font('italic small-caps 12pt Comic Sans'), 'Comic Sans', 12, ITALIC, SMALL_CAPS, NORMAL) self.assertFont(font('italic small-caps bold 12pt Comic Sans'), 'Comic Sans', 12, ITALIC, SMALL_CAPS, BOLD) self.assertFont(font('small-caps bold 12pt Comic Sans'), 'Comic Sans', 12, NORMAL, SMALL_CAPS, BOLD) self.assertFont(font('italic bold 12 pt Comic Sans'), 'Comic Sans', 12, ITALIC, NORMAL, BOLD) self.assertFont(font('bold 12 pt Comic Sans'), 'Comic Sans', 12, NORMAL, NORMAL, BOLD)
def test_invaid(self): with self.assertRaises(ValueError): font(42)
def test_weight(self): self.assertFont(font('italic small-caps bold 12pt Comic Sans'), 'Comic Sans', 12, ITALIC, SMALL_CAPS, BOLD) with self.assertRaises(ValueError): font('italic small-caps wiggly 12pt Comic Sans')
def test_variant(self): self.assertFont(font('italic small-caps 12pt Comic Sans'), 'Comic Sans', 12, ITALIC, SMALL_CAPS, NORMAL) with self.assertRaises(ValueError): font('italic wiggly bold 12pt Comic Sans')
def test_font_family(self): self.assertFont(font("12pt 'Comic Sans'"), 'Comic Sans', 12, NORMAL, NORMAL, NORMAL) self.assertFont(font('12pt "Comic Sans"'), 'Comic Sans', 12, NORMAL, NORMAL, NORMAL)