File: test_attributes.py

package info (click to toggle)
python-textile 1%3A4.0.3-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 460 kB
  • sloc: python: 2,791; makefile: 17; sh: 7
file content (24 lines) | stat: -rw-r--r-- 1,075 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
from typing import OrderedDict
from textile.utils import parse_attributes


def test_parse_attributes():
    assert parse_attributes('\\1', element='td') == {'colspan': '1'}
    assert parse_attributes('/1', element='td') == {'rowspan': '1'}
    assert parse_attributes('^', element='td') == {'style': 'vertical-align:top;'}
    assert parse_attributes('{color: blue}') == {'style': 'color: blue;'}
    assert parse_attributes('[en]') == {'lang': 'en'}
    assert parse_attributes('(cssclass)') == {'class': 'cssclass'}
    assert parse_attributes('(') == {'style': 'padding-left:1em;'}
    assert parse_attributes(')') == {'style': 'padding-right:1em;'}
    assert parse_attributes('<') == {'style': 'text-align:left;'}
    assert parse_attributes('(c#i)') == {'class': 'c', 'id': 'i'}
    assert parse_attributes('\\2 100', element='col') == {'span': '2', 'width': '100'}


def test_parse_attributes_edge_cases():
    result = parse_attributes('(:c#i)')
    expect = OrderedDict({'id': 'i'})
    assert result == expect

    assert parse_attributes('(<)') == OrderedDict()