Пример #1
0
def test_content_simple_string():
    content = Content('test', tag='p', id='id', attrs={'foo': 'foo'})
    assert content.html() == '<p foo="foo" id="id">test</p>'
    assert content.text() == 'test\n\n'
    assert content._json() == ('id', 'test')
    assert Content('test', tag='h1').text() == 'test\n====\n\n'
    assert Content('test')._json() is None
Пример #2
0
def test_content_not_escaped():
    content = Content('<a>test</a>',
                      tag='p',
                      attrs={'id': 'id<br>'},
                      escape=False)
    assert content.html() == '<p id="id&lt;br&gt;"><a>test</a></p>'
    assert content.text() == '<a>test</a>\n\n'
Пример #3
0
def test_content_simple_string():
    content = Content('test', tag='p', id='id', attrs={'foo': 'foo'})
    assert content.html() == '<p foo="foo" id="id">test</p>'
    assert content.text() == 'test\n\n'
    assert content._json() == ('id', 'test')
    assert Content('test', tag='h1').text() == 'test\n====\n\n'
    assert Content('test')._json() is None
Пример #4
0
def test_content_escaped():
    content = Content('te<br>st', tag='p', attrs={'id': 'id<br>'})
    assert content.html() == '<p id="id&lt;br&gt;">te&lt;br&gt;st</p>'
    assert content.text() == 'te<br>st\n\n'
Пример #5
0
def test_content_simple_string():
    content = Content('test', tag='p', attrs={'id': 'id'})
    assert content.html() == '<p id="id">test</p>'
    assert content.text() == 'test\n\n'
    assert Content('test', tag='h1').text() == 'test\n====\n\n'
Пример #6
0
def test_content_not_escaped():
    content = Content('<a>test</a>', tag='p', id='id<br>', escape=False)
    assert content.html() == '<p id="id&lt;br&gt;"><a>test</a></p>'
    assert content.text() == '<a>test</a>\n\n'
    assert content._json() == ('id<br>', '<a>test</a>')
Пример #7
0
def test_content_escaped():
    content = Content('te<br>st', tag='p', id='id<br>')
    assert content.html() == '<p id="id&lt;br&gt;">te&lt;br&gt;st</p>'
    assert content.text() == 'te<br>st\n\n'
    assert content._json() == ('id<br>', 'te<br>st')
Пример #8
0
def test_content_not_escaped():
    content = Content(
        '<a>test</a>', tag='p', id='id<br>', escape=False)
    assert content.html() == '<p id="id&lt;br&gt;"><a>test</a></p>'
    assert content.text() == '<a>test</a>\n\n'
    assert content._json() == ('id<br>', '<a>test</a>')
Пример #9
0
def test_content_escaped():
    content = Content('te<br>st', tag='p', id='id<br>')
    assert content.html() == '<p id="id&lt;br&gt;">te&lt;br&gt;st</p>'
    assert content.text() == 'te<br>st\n\n'
    assert content._json() == ('id<br>', 'te<br>st')