예제 #1
0
    def test_hashability(self):
        iri1 = IRI(u'http://\N{CLOUD}/')
        iri2 = IRI(u'http://\N{CLOUD}/')
        self.assertEquals(hash(iri1), hash(iri2))

        uri1 = URI(iri1)
        uri2 = URI('http://xn--l3h/')
        self.assertEquals(hash(uri1), hash(uri2))

        self.assertNotEquals(hash(iri1), hash(uri1))
예제 #2
0
    def test_ne(self):
        iri1 = IRI(u'http://\N{CLOUD}/')
        iri2 = IRI(u'http://\N{CLOUD}/')
        self.assertFalse(iri1 != iri2)

        uri1 = URI(iri1)
        uri2 = URI('http://xn--l3h/')
        self.assertFalse(uri1 != uri2)

        self.assertTrue(iri1 != uri1)
예제 #3
0
    def test_eq(self):
        iri1 = IRI(u'http://\N{CLOUD}/')
        iri2 = IRI(u'http://\N{CLOUD}/')
        self.assertEquals(iri1, iri2)

        uri1 = URI(iri1)
        uri2 = URI('http://xn--l3h/')
        self.assertEquals(uri1, uri2)

        self.assertNotEquals(iri1, uri1)
예제 #4
0
파일: test_iri.py 프로젝트: studer/uricore
 def test_convert_pile_of_poo(self):
     raise SkipTest("Not Implemented")
     uri = URI("http://*****:*****@www.xn--ls8h.la:80/path?q=arg#frag".encode('utf-8'))
     try:
         IRI(uri)
     except Exception as e:
         assert False, "{0} {1}".format(type(e), e)
예제 #5
0
 def test_convert_pile_of_poo(self):
     raise SkipTest("Not Implemented")
     iri = IRI(u"http://*****:*****@www.💩.la:80/path?q=arg#frag")
     try:
         URI(iri)
     except Exception as e:
         assert False, "{0} {1}".format(type(e), e)
예제 #6
0
 def test_uri_from_lenient(self):
     lenient_uri = URI.from_lenient(
         u'http://de.wikipedia.org/wiki/Elf (Begriffskl\xe4rung)'.encode(
             'utf-8'))
     self.assertEquals(
         repr(lenient_uri),
         "URI('http://de.wikipedia.org/wiki/Elf%20%28Begriffskl%C3%A4rung%29')"
     )
예제 #7
0
class TestURIJoin(cases.JoinAndUpdateCase):

    RI = lambda self, s: URI(self._literal_wrapper(s), encoding='utf-8')

    def _literal_wrapper(self, lit):
        return lit.encode('utf-8')

    def test_cannot_join_uri(self):
        self.assertRaises(TypeError,
                          self.RI('http://localhost:8000').join,
                          IRI(u'/path/to/file'))
예제 #8
0
class TestURIPileOfPoo(cases.IdentifierCase):

    ri = URI("http://*****:*****@www.xn--ls8h.la:80/path?q=arg#frag")
    expect = dict(
        scheme="http",
        auth="u:p",
        hostname="www.xn--ls8h.la",
        port="80",
        path="/path",
        query=MultiDict([('q', 'arg')]),
        querystr='q=arg',
        fragment="frag",
        netloc="u:[email protected]:80",
    )
예제 #9
0
class TestURISnowman(cases.IdentifierCase):

    ri = URI("http://*****:*****@www.%s:80/path?q=arg#frag" %
             u"\N{SNOWMAN}".encode('idna'))
    expect = dict(
        scheme="http",
        auth="u:p",
        hostname="www.xn--n3h",
        port="80",
        path="/path",
        query=MultiDict([('q', 'arg')]),
        querystr='q=arg',
        fragment="frag",
        netloc="u:[email protected]:80",
    )
예제 #10
0
class TestURIConvertedSnowman(cases.IdentifierCase):

    iri = IRI(u"http://*****:*****@www.\N{SNOWMAN}:80/path?q=arg#frag")
    ri = URI(iri)
    expect = dict(
        scheme="http",
        auth="u:p",
        hostname="www.xn--n3h",
        port="80",
        path="/path",
        query=MultiDict([('q', 'arg')]),
        querystr='q=arg',
        fragment="frag",
        netloc="u:[email protected]:80",
    )
예제 #11
0
파일: test_iri.py 프로젝트: studer/uricore
class TestIRIConvertedSnowman(cases.IdentifierCase):

    uri = URI(("http://*****:*****@www.%s:80/path?q=arg#frag"
               % u"\N{SNOWMAN}".encode('idna')).encode('utf-8'))
    ri = IRI(uri)
    expect = dict(
        scheme="http",
        auth="u:p",
        hostname="www.\u2603",
        port="80",
        path="/path",
        query=MultiDict([('q', 'arg')]),
        querystr='q=arg',
        fragment="frag",
        netloc="u:p@www.\u2603:80",
    )
예제 #12
0
 def test_uri_from_lenient(self):
     lenient_uri = URI.from_lenient(u'http://de.wikipedia.org/wiki/Elf (Begriffskl\xe4rung)'.encode('utf-8'))
     self.assertEquals(repr(lenient_uri), "URI('http://de.wikipedia.org/wiki/Elf%20%28Begriffskl%C3%A4rung%29')")
예제 #13
0
 def test_idn_ascii_encoding(self):
     uri = URI(u"http://Bücher.ch/".encode('utf-8'))
     self.assertEquals(str(uri), "http://xn--bcher-kva.ch/")
예제 #14
0
 def setUp(self):
     self.uri = URI("http://example.com?foo=bar")
예제 #15
0
 def test_non_existent_scheme(self):
     try:
         URI("watwatwat://wat.wat/wat")
     except Exception as e:
         assert False, "{0} {1}".format(type(e), e)
예제 #16
0
파일: test_iri.py 프로젝트: studer/uricore
 def test_uri_input(self):
     iri = TestIRISnowman.ri
     uri = URI(iri)
     self.assertEquals(str(iri), str(IRI(uri)))
     self.assertEquals(unicode(iri), unicode(IRI(uri)))
예제 #17
0
파일: test_iri.py 프로젝트: studer/uricore
 def test_cannot_join_uri(self):
     self.assertRaises(TypeError,
                       IRI('http://localhost:8000').join,
                       URI(str('/path/to/file'))
                      )
예제 #18
0
 def test_iri_input(self):
     uri = TestURISnowman.ri
     iri = IRI(uri)
     self.assertEquals(str(uri), str(URI(iri)))
     self.assertEquals(unicode(uri), unicode(URI(iri)))
예제 #19
0
def test_uri_template():
    eq_(URI("http://example.com/value"),
        URI.from_template("http://example.com/{var}", var="value"))
예제 #20
0
def test_uri_template():
    eq_(URI("http://example.com/value"),
        URI.from_template("http://example.com/{var}", var="value"))