Esempio n. 1
0
def test_common_prefix():
    """Test finding out what the common prefix is"""
    css_file = os.path.join('files', 'test-foo.css')
    obj = icon_font.IconFont(css_file=css_file, ttf_file=None,
                             keep_prefix=True)
    assert obj.common_prefix == 'foo-'

    css_file = os.path.join('files', 'test.css')
    obj = icon_font.IconFont(css_file=css_file, ttf_file=None,
                             keep_prefix=True)
    assert obj.common_prefix == ''
def test_init():
    """Test initializing"""
    # No arguments
    with pytest.raises(TypeError):
        icon_font.IconFont()

    # Non-existent files
    with pytest.raises(IOError):
        icon_font.IconFont(css_file=str(uuid.uuid4()),
                           ttf_file=str(uuid.uuid4()))

    obj = icon_font.IconFont(css_file=tempfile.mkstemp()[1],
                             ttf_file=tempfile.mkstemp()[1])
    assert len(obj.css_icons) == 0
def octicons():
    """Create a IconFont instance from Octicons files"""
    css_file = os.path.join(BASE_DIR, 'files', 'octicons.css')
    ttf_file = os.path.join(BASE_DIR, 'files', 'octicons.ttf')
    return icon_font.IconFont(css_file=css_file, ttf_file=ttf_file)
def font_awesome():
    """Create a IconFont instance from Font Awesome files"""
    css_file = os.path.join(BASE_DIR, 'files', 'font-awesome.css')
    ttf_file = os.path.join(BASE_DIR, 'files', 'fontawesome-webfont.ttf')
    return icon_font.IconFont(css_file=css_file, ttf_file=ttf_file)