Пример #1
0
def test_trim_url_trailing_char_and_enclosing(trailing_char, left, right):
    test_url = 'http://example.com/'
    assert test_url == trim_url(test_url + right + trailing_char)

    # assert the trailing char is kept if there is something else
    test_url = 'http://example.com/' + trailing_char
    assert test_url == trim_url(test_url + right)
Пример #2
0
def test_trim_url_remove_trailing_char(trailing_char):
    test_url = 'http://example.com/'
    assert trim_url(test_url + trailing_char) == test_url

    # assert trailing_char removed only if it is trailing
    test_url = 'http://example.com/' + trailing_char + 'content'
    assert trim_url(test_url) == test_url
Пример #3
0
def test_trim_url_remove_trailing_enclosing(left, right):
    # right without left => right is removed
    test_url = 'http://example.com/'
    assert test_url == trim_url(test_url + right)

    # right after path without left => right is removed
    test_url = 'http://example.com/a'
    assert test_url == trim_url(test_url + right)

    # trailing left without right => left is kept
    test_url = 'http://example.com/a' + left
    assert test_url == trim_url(test_url)

    # left before content without right => left is kept
    test_url = 'http://example.com/a' + left + 'something'
    assert test_url == trim_url(test_url)

    # left + content + right => right is kept
    assert test_url + right == trim_url(test_url + right)