File: test_utils.py

package info (click to toggle)
python-textile 1%3A2.3.5-1
  • links: PTS, VCS
  • area: main
  • in suites: stretch
  • size: 444 kB
  • ctags: 233
  • sloc: python: 2,320; makefile: 4
file content (30 lines) | stat: -rw-r--r-- 1,118 bytes parent folder | download | duplicates (4)
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
# -*- coding: utf-8 -*-
from __future__ import unicode_literals

from textile import utils

def test_encode_html():
    result = utils.encode_html('''this is a "test" of text that's safe to '''
            'put in an <html> attribute.')
    expect = ('this is a &quot;test&quot; of text that&#39;s safe to put in '
            'an &lt;html&gt; attribute.')
    assert result == expect

def test_has_raw_text():
    assert utils.has_raw_text('<p>foo bar biz baz</p>') is False
    assert utils.has_raw_text(' why yes, yes it does') is True

def test_is_rel_url():
    assert utils.is_rel_url("http://www.google.com/") is False
    assert utils.is_rel_url("/foo") is True

def test_generate_tag():
    result = utils.generate_tag('span', 'inner text', {'class': 'test'})
    expect = '<span class="test">inner text</span>'
    assert result == expect

    text = 'Übermensch'
    attributes = {'href': 'http://de.wikipedia.org/wiki/%C3%C9bermensch'}
    expect = '<a href="http://de.wikipedia.org/wiki/%C3%C9bermensch">Übermensch</a>'
    result = utils.generate_tag('a', text, attributes)
    assert result == expect