Пример #1
0
    def test_variant(self):
        self.assertFont(Font('Comic Sans', 12, variant=SMALL_CAPS),
                        'Comic Sans', 12, NORMAL, SMALL_CAPS, NORMAL)

        self.assertFont(Font('Comic Sans', 12, variant='small-caps'),
                        'Comic Sans', 12, NORMAL, SMALL_CAPS, NORMAL)

        self.assertFont(Font('Comic Sans', 12, variant='something else'),
                        'Comic Sans', 12, NORMAL, NORMAL, NORMAL)
Пример #2
0
    def test_weight(self):
        self.assertFont(Font('Comic Sans', 12, weight=BOLD), 'Comic Sans', 12,
                        NORMAL, NORMAL, BOLD)

        self.assertFont(Font('Comic Sans', 12, weight='bold'), 'Comic Sans',
                        12, NORMAL, NORMAL, BOLD)

        self.assertFont(Font('Comic Sans', 12, weight='something else'),
                        'Comic Sans', 12, NORMAL, NORMAL, NORMAL)
Пример #3
0
    def test_hash(self):
        self.assertEqual(
            hash(Font('Comic Sans', 12)),
            hash(Font('Comic Sans', 12)),
        )

        self.assertNotEqual(
            hash(Font('Comic Sans', 12, weight=BOLD)),
            hash(Font('Comic Sans', 12)),
        )
Пример #4
0
    def test_family(self):
        self.assertFont(Font('Comic Sans', 12), 'Comic Sans', 12, NORMAL,
                        NORMAL, NORMAL)

        self.assertFont(Font('Wingdings', 12), 'Wingdings', 12, NORMAL, NORMAL,
                        NORMAL)

        self.assertFont(Font("'Comic Sans'", 12), 'Comic Sans', 12, NORMAL,
                        NORMAL, NORMAL)

        self.assertFont(Font('"Comic Sans"', 12), 'Comic Sans', 12, NORMAL,
                        NORMAL, NORMAL)
Пример #5
0
    def test_style(self):
        self.assertFont(Font('Comic Sans', 12, style=ITALIC), 'Comic Sans', 12,
                        ITALIC, NORMAL, NORMAL)

        self.assertFont(Font('Comic Sans', 12, style='italic'), 'Comic Sans',
                        12, ITALIC, NORMAL, NORMAL)

        self.assertFont(Font('Comic Sans', 12, style=OBLIQUE), 'Comic Sans',
                        12, OBLIQUE, NORMAL, NORMAL)

        self.assertFont(Font('Comic Sans', 12, style='oblique'), 'Comic Sans',
                        12, OBLIQUE, NORMAL, NORMAL)

        self.assertFont(Font('Comic Sans', 12, style='something else'),
                        'Comic Sans', 12, NORMAL, NORMAL, NORMAL)
Пример #6
0
    def test_font_instance(self):
        f = Font('Comic Sans', 12)

        parsed = font(f)

        self.assertEqual(f, parsed)
        self.assertIs(f, parsed)
Пример #7
0
    def test_repr(self):
        self.assertEqual(repr(Font('Comic Sans', 12)),
                         '<Font: 12pt Comic Sans>')

        self.assertEqual(repr(Font('Comic Sans', 12, style=ITALIC)),
                         '<Font: italic 12pt Comic Sans>')

        self.assertEqual(
            repr(Font('Comic Sans', 12, style=ITALIC, variant=SMALL_CAPS)),
            '<Font: italic small-caps 12pt Comic Sans>')

        self.assertEqual(
            repr(
                Font('Comic Sans',
                     12,
                     style=ITALIC,
                     variant=SMALL_CAPS,
                     weight=BOLD)),
            '<Font: italic small-caps bold 12pt Comic Sans>')

        self.assertEqual(
            repr(Font('Comic Sans', 12, variant=SMALL_CAPS, weight=BOLD)),
            '<Font: small-caps bold 12pt Comic Sans>')

        self.assertEqual(repr(Font('Comic Sans', 12, weight=BOLD)),
                         '<Font: bold 12pt Comic Sans>')

        self.assertEqual(
            repr(Font('Comic Sans', 12, style=ITALIC, weight=BOLD)),
            '<Font: italic bold 12pt Comic Sans>')
Пример #8
0
    def test_simple_construction(self):
        # Simplest case
        self.assertFont(Font('Comic Sans', 12), 'Comic Sans', 12, NORMAL,
                        NORMAL, NORMAL)

        # String size
        self.assertFont(Font('Comic Sans', '12'), 'Comic Sans', 12, NORMAL,
                        NORMAL, NORMAL)

        # String size with 'pt'
        self.assertFont(Font('Comic Sans', '12pt'), 'Comic Sans', 12, NORMAL,
                        NORMAL, NORMAL)

        self.assertFont(Font('Comic Sans', '12 pt'), 'Comic Sans', 12, NORMAL,
                        NORMAL, NORMAL)

        with self.assertRaises(ValueError):
            Font('Comic Sans', '12 quatloos'),
Пример #9
0
    def test_make_normal_style(self):
        f = Font('Comic Sans', 12)
        self.assertFont(f.normal_style(), 'Comic Sans', 12, NORMAL, NORMAL,
                        NORMAL)

        f = Font('Comic Sans', 12, style=ITALIC)
        self.assertFont(f.normal_style(), 'Comic Sans', 12, NORMAL, NORMAL,
                        NORMAL)
Пример #10
0
    def test_make_normal_weight(self):
        f = Font('Comic Sans', 12)
        self.assertFont(f.normal_weight(), 'Comic Sans', 12, NORMAL, NORMAL,
                        NORMAL)

        f = Font('Comic Sans', 12, weight=BOLD)
        self.assertFont(f.normal_weight(), 'Comic Sans', 12, NORMAL, NORMAL,
                        NORMAL)
Пример #11
0
    def test_make_normal_variant(self):
        f = Font('Comic Sans', 12)
        self.assertFont(f.normal_variant(), 'Comic Sans', 12, NORMAL, NORMAL,
                        NORMAL)

        f = Font('Comic Sans', 12, variant=SMALL_CAPS)
        self.assertFont(f.normal_variant(), 'Comic Sans', 12, NORMAL, NORMAL,
                        NORMAL)
Пример #12
0
    def test_repr(self):
        self.assertEqual(repr(Font('Comic Sans', 12)),
                         '<Font: 12pt Comic Sans>')

        self.assertEqual(repr(Font('Comic Sans', 12, style=ITALIC)),
                         '<Font: italic 12pt Comic Sans>')

        self.assertEqual(
            repr(Font('Comic Sans', 12, style=ITALIC, variant=SMALL_CAPS)),
            '<Font: italic small-caps 12pt Comic Sans>')

        self.assertEqual(
            repr(
                Font('Comic Sans',
                     12,
                     style=ITALIC,
                     variant=SMALL_CAPS,
                     weight=BOLD)),
            '<Font: italic small-caps bold 12pt Comic Sans>')

        self.assertEqual(
            repr(Font('Comic Sans', 12, variant=SMALL_CAPS, weight=BOLD)),
            '<Font: small-caps bold 12pt Comic Sans>')

        self.assertEqual(repr(Font('Comic Sans', 12, weight=BOLD)),
                         '<Font: bold 12pt Comic Sans>')

        self.assertEqual(
            repr(Font('Comic Sans', 12, style=ITALIC, weight=BOLD)),
            '<Font: italic bold 12pt Comic Sans>')

        # Check system default size handling
        self.assertEqual(repr(Font('Comic Sans', SYSTEM_DEFAULT_FONT_SIZE)),
                         '<Font: system default size Comic Sans>')

        self.assertEqual(
            repr(Font('Comic Sans', SYSTEM_DEFAULT_FONT_SIZE, style=ITALIC)),
            '<Font: italic system default size Comic Sans>')
Пример #13
0
 def test_equality(self):
     self.assertEqual(Font('Comic Sans', '12 pt'),
                      Font('Comic Sans', 12, NORMAL, NORMAL, NORMAL))
Пример #14
0
 def test_make_bold(self):
     f = Font('Comic Sans', 12)
     self.assertFont(f.bold(), 'Comic Sans', 12, NORMAL, NORMAL, BOLD)
Пример #15
0
 def test_make_small_caps(self):
     f = Font('Comic Sans', 12)
     self.assertFont(f.small_caps(), 'Comic Sans', 12, NORMAL, SMALL_CAPS,
                     NORMAL)
Пример #16
0
 def test_make_italic(self):
     f = Font('Comic Sans', 12)
     self.assertFont(f.italic(), 'Comic Sans', 12, ITALIC, NORMAL, NORMAL)
Пример #17
0
 def test_make_oblique(self):
     f = Font('Comic Sans', 12)
     self.assertFont(f.oblique(), 'Comic Sans', 12, OBLIQUE, NORMAL, NORMAL)