File: test_font_trait.py

package info (click to toggle)
python-traitsui 4.4.0-1.3
  • links: PTS, VCS
  • area: main
  • in suites: jessie, jessie-kfreebsd
  • size: 3,680 kB
  • ctags: 6,394
  • sloc: python: 32,786; makefile: 16; sh: 5
file content (48 lines) | stat: -rw-r--r-- 1,177 bytes parent folder | download | duplicates (2)
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
48

from nose.tools import assert_equals

from traits.api import HasTraits, Font

from traitsui.tests._tools import *


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


@skip_if_not_null
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')