def test_svg_icon_loads_icon():
    def read_icon(name):
        return '<svg id="{}"></svg>'.format(name)

    result = ext.svg_icon(read_icon, "settings")

    assert result == Markup('<svg class="svg-icon" id="settings" />')
def test_svg_icon_sets_css_class():
    def read_icon(name):
        return "<svg></svg>"

    result = ext.svg_icon(read_icon, "icon", css_class="fancy-icon")

    assert result == Markup('<svg class="svg-icon fancy-icon" />')
示例#3
0
def test_svg_icon_sets_css_class():
    def read_icon(name):
        return '<svg></svg>'

    result = ext.svg_icon(read_icon, 'icon', css_class='fancy-icon')

    assert result == Markup('<svg class="fancy-icon" />')
示例#4
0
def test_svg_icon_sets_css_class():
    def read_icon(name):
        return '<svg></svg>'

    result = ext.svg_icon(read_icon, 'icon', css_class='fancy-icon')

    assert result == Markup('<svg class="svg-icon fancy-icon" />')
示例#5
0
def test_svg_icon_strips_default_xml_namespace():
    def read_icon(name):
        return '<svg xmlns="http://www.w3.org/2000/svg"></svg>'

    assert (ext.svg_icon(
        read_icon,
        'icon') == Markup('<svg xmlns="http://www.w3.org/2000/svg" />'))
示例#6
0
def test_svg_icon_loads_icon():
    def read_icon(name):
        return '<svg id="{}"></svg>'.format(name)

    result = ext.svg_icon(read_icon, 'settings')

    assert result == Markup('<svg id="settings" />')
示例#7
0
def test_svg_icon_removes_title():
    def read_icon(name):
        return '<svg xmlns="http://www.w3.org/2000/svg"><title>foo</title></svg>'

    assert (ext.svg_icon(
        read_icon,
        'icon') == Markup('<svg xmlns="http://www.w3.org/2000/svg" />'))
示例#8
0
def test_svg_icon_sets_css_class():
    def read_icon(name):
        return "<svg></svg>"

    result = ext.svg_icon(read_icon, "icon", css_class="fancy-icon")

    assert result == Markup('<svg class="svg-icon fancy-icon" />')
示例#9
0
def test_svg_icon_strips_default_xml_namespace():
    def read_icon(name):
        return '<svg xmlns="http://www.w3.org/2000/svg"></svg>'

    assert ext.svg_icon(read_icon, "icon") == Markup(
        '<svg xmlns="http://www.w3.org/2000/svg" class="svg-icon" />'
    )
示例#10
0
def test_svg_icon_removes_title():
    def read_icon(name):
        return '<svg xmlns="http://www.w3.org/2000/svg"><title>foo</title></svg>'

    assert ext.svg_icon(read_icon, "icon") == Markup(
        '<svg xmlns="http://www.w3.org/2000/svg" class="svg-icon" />'
    )
示例#11
0
def test_svg_icon_loads_icon():
    def read_icon(name):
        return '<svg id="{}"></svg>'.format(name)

    result = ext.svg_icon(read_icon, "settings")

    # nb. The order of attributes can differ depending on the Python version.
    # In Python 3.9+ the `id` attribute is first.
    assert result in [
        Markup('<svg class="svg-icon" id="settings" />'),
        Markup('<svg id="settings" class="svg-icon" />'),
    ]
示例#12
0
文件: svg_icon_test.py 项目: kaydoh/h
    def test_it_removes_title(self, icon_file):
        icon_file.write(
            '<svg xmlns="http://www.w3.org/2000/svg"><title>foo</title></svg>')

        assert svg_icon("test_icon_name") == Markup(
            '<svg xmlns="http://www.w3.org/2000/svg" class="svg-icon" />')
示例#13
0
文件: svg_icon_test.py 项目: kaydoh/h
    def test_it_sets_css_class(self, icon_file, css_class, expected):
        icon_file.write("<svg></svg>")

        result = svg_icon("test_icon_name", css_class=css_class)

        assert result == Markup(f'<svg class="{expected}" />')
示例#14
0
文件: svg_icon_test.py 项目: kaydoh/h
    def test_it_strips_default_xml_namespace(self, icon_file):
        icon_file.write('<svg xmlns="http://www.w3.org/2000/svg"></svg>')

        assert svg_icon("test_icon_name") == Markup(
            '<svg xmlns="http://www.w3.org/2000/svg" class="svg-icon" />')