File: test_utils.py

package info (click to toggle)
manimpango 0.6.1-2
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 6,804 kB
  • sloc: python: 1,252; sh: 164; makefile: 18
file content (40 lines) | stat: -rw-r--r-- 1,359 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
# -*- coding: utf-8 -*-
import pytest

from manimpango.enums import Style, Weight
from manimpango.utils import PangoUtils


def test_str2style():
    p = PangoUtils()

    assert p.str2style("NORMAL") == Style.NORMAL
    assert p.str2style("ITALIC") == Style.ITALIC
    assert p.str2style("OBLIQUE") == Style.OBLIQUE

    with pytest.raises(AttributeError) as exc_info:
        p.str2style("DNE")
    exception_raised = exc_info.value
    assert "There is no Style Called DNE" == str(exception_raised)


def test_str2weight():
    p = PangoUtils()

    assert p.str2weight("NORMAL") == Weight.NORMAL
    assert p.str2weight("BOLD") == Weight.BOLD
    assert p.str2weight("THIN") == Weight.THIN
    assert p.str2weight("THIN") == Weight.THIN
    assert p.str2weight("ULTRALIGHT") == Weight.ULTRALIGHT
    assert p.str2weight("LIGHT") == Weight.LIGHT
    assert p.str2weight("BOOK") == Weight.BOOK
    assert p.str2weight("MEDIUM") == Weight.MEDIUM
    assert p.str2weight("SEMIBOLD") == Weight.SEMIBOLD
    assert p.str2weight("ULTRABOLD") == Weight.ULTRABOLD
    assert p.str2weight("HEAVY") == Weight.HEAVY
    assert p.str2weight("ULTRAHEAVY") == Weight.ULTRAHEAVY

    with pytest.raises(AttributeError) as exc_info:
        p.str2weight("DNE")
    exception_raised = exc_info.value
    assert "There is no Font Weight Called DNE" == str(exception_raised)