示例#1
0
def testTrailingSpaces():
    """Trailing spaces after URL"""
    assert ["http://tomtom.foobar.org/"] == grab(
        "http://tomtom.foobar.org/     ", needScheme
    )
    assert ["http://www.foobi.org/saatoimia"] == grab(
        "http://www.foobi.org/saatoimia    ", needScheme
    )
示例#2
0
def testLeadingSpaces():
    """Leading spaces before URL"""
    assert ["http://tomtom.foobar.org/"] == grab(
        "     http://tomtom.foobar.org/", needScheme
    )
    assert ["http://www.foobi.org/saatoimia"] == grab(
        "  http://www.foobi.org/saatoimia", needScheme
    )
示例#3
0
def testIPv6noscheme():
    """IPv6 URL without a scheme"""
    if needScheme:
        return
    assert ["[2001:a68:104:1337:250:daff:fe72:871c]/toimia"] == grab(
        "foo [2001:a68:104:1337:250:daff:fe72:871c]/toimia", needScheme
    )
示例#4
0
def testIPv6noscheme():
    """IPv6 URL without a scheme"""
    if needScheme:
        return
    assert ["[2001:a68:104:1337:250:daff:fe72:871c]/toimia"
            ] == grab("foo [2001:a68:104:1337:250:daff:fe72:871c]/toimia",
                      needScheme)
示例#5
0
def testScandinavian():
    """Test åäö"""
    assert [
        "http://www.hs.fi/kotimaa/artikkeli/Äidin+avovaimosta+lapsen+toinen+huoltaja+KKOn+päätöksellä/1135253379084"
    ] == grab(
        "http://www.hs.fi/kotimaa/artikkeli/Äidin+avovaimosta+lapsen+toinen+huoltaja+KKOn+päätöksellä/1135253379084",
        needScheme,
    )
示例#6
0
def testScandinavian():
    """Test åäö"""
    assert [
        "http://www.hs.fi/kotimaa/artikkeli/Äidin+avovaimosta+lapsen+toinen+huoltaja+KKOn+päätöksellä/1135253379084"
    ] == grab(
        "http://www.hs.fi/kotimaa/artikkeli/Äidin+avovaimosta+lapsen+toinen+huoltaja+KKOn+päätöksellä/1135253379084",
        needScheme,
    )
示例#7
0
def testBlocks():
    """Test blocks"""
    assert [
            'http://link1.com',
            'http://link2.com',
            'http://link3.com',
            'http://link4.com',
            'http://link5.com',
    ] == grab('(http://link1.com) <http://link2.com> "http://link3.com" \'http://link4.com\' [http://link5.com]', needScheme)
示例#8
0
def testRedirect():
    """Redirect URL"""
    assert [
        "http://rediretinmyurl.com/http://dest.url.org/1/2/3/4?434",
        "http://secondurl.com",
        "ftp://1.2.3.4/adsfasdf",
    ] == grab(
        "http://rediretinmyurl.com/http://dest.url.org/1/2/3/4?434 http://secondurl.com ftp://1.2.3.4/adsfasdf",
        needScheme,
    )
示例#9
0
def testRedirect():
    """Redirect URL"""
    assert [
        "http://rediretinmyurl.com/http://dest.url.org/1/2/3/4?434",
        "http://secondurl.com",
        "ftp://1.2.3.4/adsfasdf",
    ] == grab(
        "http://rediretinmyurl.com/http://dest.url.org/1/2/3/4?434 http://secondurl.com ftp://1.2.3.4/adsfasdf",
        needScheme,
    )
示例#10
0
def testBlocks():
    """Test blocks"""
    assert [
        "http://link1.com",
        "http://link2.com",
        "http://link3.com",
        "http://link4.com",
        "http://link5.com",
    ] == grab(
        "(http://link1.com) <http://link2.com> \"http://link3.com\" 'http://link4.com' [http://link5.com]",
        needScheme,
    )
示例#11
0
def testBlocks():
    """Test blocks"""
    assert [
        "http://link1.com",
        "http://link2.com",
        "http://link3.com",
        "http://link4.com",
        "http://link5.com",
    ] == grab(
        "(http://link1.com) <http://link2.com> \"http://link3.com\" 'http://link4.com' [http://link5.com]",
        needScheme,
    )
示例#12
0
def testLeadingText():
    """Leading text"""
    assert ["http://www.technikfoo.de/mai"] == grab(
        "here it is: http://www.technikfoo.de/mai", needScheme
    )
示例#13
0
def testLeadingAndTrailingText():
    """Leading and trailing text"""
    assert ["http://123.123.123.123"] == grab(
        "fooasdf asdf a http://123.123.123.123 asdfasdf", needScheme
    )
示例#14
0
def testLongURL():
    """A long URL-like string"""
    assert [] == grab(
        "www.www.www.www.www.www.www.www.www.www.www.www.www.www.www.www.www.www.www.www.www.www.www.www.www.www.www.www.www.www.www.www.www.www.www.www.www.www.www.www.www.www.www.www.www.www.www.www.www.www.www.www.www",
        needScheme,
    )
示例#15
0
def testQuestionMarkURI():
    """An URI with a question mark"""
    assert ["http://www.bdog.fi/cgi-bin/netstore/tuotehaku.pl?tuoteryhma=16"] == grab(
        "http://www.bdog.fi/cgi-bin/netstore/tuotehaku.pl?tuoteryhma=16", needScheme
    )
示例#16
0
def testIPv6():
    """IPv6 URL with scheme"""
    assert ["http://[2001:a68:104:1337:250:daff:fe72:871c]/toimia"] == grab(
        "foo http://[2001:a68:104:1337:250:daff:fe72:871c]/toimia", needScheme
    )
示例#17
0
def testIPv6():
    """IPv6 URL with scheme"""
    assert ["http://[2001:a68:104:1337:250:daff:fe72:871c]/toimia"] == grab(
        "foo http://[2001:a68:104:1337:250:daff:fe72:871c]/toimia", needScheme)
示例#18
0
def testAnchor():
    """Link with an anchor tag"""
    assert ["http://foo.com/page.html#anchor"] == grab(
        "http://foo.com/page.html#anchor", needScheme
    )
示例#19
0
def testFoobarIP():
    """ip number-like text"""
    assert [] == grab(
        "http://11123.123.123.123/eisaa http://123.123.123.12345/eisaa", needScheme
    )
示例#20
0
def testRedirect():
    """Redirect URL"""
    assert ['http://rediretinmyurl.com/http://dest.url.org/1/2/3/4?434', 'http://secondurl.com', 'ftp://1.2.3.4/adsfasdf'] == grab('http://rediretinmyurl.com/http://dest.url.org/1/2/3/4?434 http://secondurl.com ftp://1.2.3.4/adsfasdf', needScheme)
示例#21
0
def testLeadingText():
    """Leading text"""
    assert ["http://www.technikfoo.de/mai"
            ] == grab("here it is: http://www.technikfoo.de/mai", needScheme)
示例#22
0
def testLeadingSpaces():
    """Leading spaces before URL"""
    assert ["http://tomtom.foobar.org/"
            ] == grab("     http://tomtom.foobar.org/", needScheme)
    assert ["http://www.foobi.org/saatoimia"
            ] == grab("  http://www.foobi.org/saatoimia", needScheme)
示例#23
0
def testNoScheme():
    """URI without a scheme"""
    if needScheme:
        return
    assert ["123.123.123.123"] == grab("123.123.123.123", needScheme)
示例#24
0
def testLeadingAndTrailingText():
    """Leading and trailing text"""
    assert ["http://123.123.123.123"
            ] == grab("fooasdf asdf a http://123.123.123.123 asdfasdf",
                      needScheme)
示例#25
0
def testIP():
    """http URI with an ip number"""
    assert ["http://234.234.234.234"] == grab("http://234.234.234.234", needScheme)
示例#26
0
def testQuestionMarkURI():
    """An URI with a question mark"""
    assert [
        "http://www.bdog.fi/cgi-bin/netstore/tuotehaku.pl?tuoteryhma=16"
    ] == grab("http://www.bdog.fi/cgi-bin/netstore/tuotehaku.pl?tuoteryhma=16",
              needScheme)
示例#27
0
def testTrailingSpaces():
    """Trailing spaces after URL"""
    assert ["http://tomtom.foobar.org/"
            ] == grab("http://tomtom.foobar.org/     ", needScheme)
    assert ["http://www.foobi.org/saatoimia"
            ] == grab("http://www.foobi.org/saatoimia    ", needScheme)
示例#28
0
def testNoScheme():
    """URI without a scheme"""
    if needScheme:
        return
    assert ["123.123.123.123"] == grab("123.123.123.123", needScheme)
示例#29
0
def test2URIs():
    """2 URIs on same text"""
    assert ["http://foobar.fi/1234{}[]{}", "http://127.0.0.1/"] == grab(
        "http://foobar.fi/1234{}[]{} sadfljs dlfkjsd lf;asdf http://127.0.0.1/",
        needScheme,
    )
示例#30
0
def testFoobarIP():
    """ip number-like text"""
    assert [] == grab(
        "http://11123.123.123.123/eisaa http://123.123.123.12345/eisaa",
        needScheme)
示例#31
0
def testLongURL():
    """A long URL-like string"""
    assert [] == grab(
        "www.www.www.www.www.www.www.www.www.www.www.www.www.www.www.www.www.www.www.www.www.www.www.www.www.www.www.www.www.www.www.www.www.www.www.www.www.www.www.www.www.www.www.www.www.www.www.www.www.www.www.www.www",
        needScheme,
    )
示例#32
0
def test2URIs():
    """2 URIs on same text"""
    assert ["http://foobar.fi/1234{}[]{}", "http://127.0.0.1/"] == grab(
        "http://foobar.fi/1234{}[]{} sadfljs dlfkjsd lf;asdf http://127.0.0.1/",
        needScheme,
    )
示例#33
0
def testAnchor():
    """Link with an anchor tag"""
    assert ["http://foo.com/page.html#anchor"
            ] == grab("http://foo.com/page.html#anchor", needScheme)
示例#34
0
def testIP():
    """http URI with an ip number"""
    assert ["http://234.234.234.234"] == grab("http://234.234.234.234",
                                              needScheme)