File: test_features.py

package info (click to toggle)
python-babelfont 3.0.6~ds-3
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 5,740 kB
  • sloc: xml: 33,013; python: 5,762; makefile: 68
file content (30 lines) | stat: -rw-r--r-- 1,028 bytes parent folder | download
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
from babelfont import Features


def test_parse():
    features = Features.from_fea("""
lookup foobar { 
    sub a by b;                                 
} foobar;
@group_one = [a b c];
@group_two = [@group_one d e f];
feature test {
    sub X by Y;
} test;
lookup foobar2 { sub c by d; } foobar2;
# Prefix: namedPrefix
lookup foobar3 {
    sub e by f;                                 
} foobar3;
feature test {
    pos X Y -150;
} test;
""")
    assert "group_one" in features.classes
    assert features.classes["group_one"] == ["a", "b", "c"]
    assert features.classes["group_two"] == ["@group_one", "d", "e", "f"]
    assert features.prefixes["anonymous"] == "lookup foobar {\n    sub a by b;\n} foobar;\nlookup foobar2 {\n    sub c by d;\n} foobar2;\n"
    assert len(features.features) == 2
    assert features.prefixes["namedPrefix"] == "lookup foobar3 {\n    sub e by f;\n} foobar3;\n"
    assert features.features[0] == ("test", "    sub X by Y;\n")
    assert features.features[1] == ("test", "    pos X Y -150;\n")