File: test_font_trait.py

package info (click to toggle)
python-traitsui 4.1.0-1
  • links: PTS, VCS
  • area: main
  • in suites: wheezy
  • size: 13,292 kB
  • sloc: python: 39,867; makefile: 120; sh: 5
file content (47 lines) | stat: -rw-r--r-- 1,175 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
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47

from nose.tools import assert_equals

from traits.api import HasTraits, Font

from traits.etsconfig.api import ETSConfig
ETSConfig.toolkit = 'null'


def test_font_trait_default():
    class Foo(HasTraits):
        font = Font()
    f = Foo()
    assert_equals(f.font, '10 pt Arial')


def test_font_trait_examples():
    """
    An assigned font string is parsed, and the substrings are
    put in the order: point size, family, style, weight, underline, facename

    The words 'pt, 'point' and 'family' are ignored.

    """
    class Foo(HasTraits):
        font = Font

    f = Foo(font='Qwerty 10')
    assert_equals(f.font, '10 pt Qwerty')

    f = Foo(font='nothing')
    assert_equals(f.font, 'nothing')

    f = Foo(font='swiss family arial')
    assert_equals(f.font, 'swiss arial')

    f = Foo(font='12 pt bold italic')
    assert_equals(f.font, '12 pt italic bold')

    f = Foo(font='123 Foo bar slant')
    assert_equals(f.font, '123 pt slant Foo bar')

    f = Foo(font='123 point Foo family bar slant')
    assert_equals(f.font, '123 pt slant Foo bar')

    f = Foo(font='16 xyzzy underline slant')
    assert_equals(f.font, '16 pt slant underline xyzzy')