示例#1
0
    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')
示例#2
0
    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)
示例#3
0
    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')
示例#4
0
    def test_font_instance(self):
        f = Font('Comic Sans', 12)

        parsed = font(f)

        self.assertEqual(f, parsed)
        self.assertIs(f, parsed)
示例#5
0
    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')
示例#6
0
    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)
示例#7
0
 def test_invaid(self):
     with self.assertRaises(ValueError):
         font(42)
示例#8
0
    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')
示例#9
0
    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')
示例#10
0
    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)