Пример #1
0
 def test_encode_hostname_idna(self):
     assert (URLObject.from_iri(u('https://\xe9xample.com/')) ==
             'https://xn--xample-9ua.com/')
Пример #2
0
 def test_add_encodes_non_ascii_and_reserved_characters(self):
     assert URLPath('/a/b/c').add(u('d /\N{LATIN SMALL LETTER E WITH ACUTE}')) == '/a/b/c/d%20/%C3%A9'
Пример #3
0
 def test_add_param_encodes_utf8(self):
     s = QueryString("abc=123")
     assert s.add_param("foo", u("\ufffd")) == "abc=123&foo=%EF%BF%BD"
Пример #4
0
 def test_quote_other_special_characters(self):
     assert (URLObject.from_iri(u('https://example.com/foo bar/')) ==
         'https://example.com/foo%20bar/')
Пример #5
0
 def test_add_param_encodes_utf8(self):
     s = QueryString('abc=123')
     assert s.add_param('foo', u('\ufffd')) == 'abc=123&foo=%EF%BF%BD'
Пример #6
0
 def test_encode_query(self):
     assert (URLObject.from_iri(u('https://example.com/?k\xe9y=v\xe5l&key2=val2')) ==
             'https://example.com/?k%C3%A9y=v%C3%A5l&key2=val2')
Пример #7
0
 def test_path_params(self):
     assert (URLObject.from_iri(u('https://example.com/foo;p\xe5rameter')) ==
             'https://example.com/foo;p%C3%A5rameter')
Пример #8
0
 def test_encode_fragment(self):
     assert (URLObject.from_iri(u('https://example.com/#fr\xe5gment')) ==
             'https://example.com/#fr%C3%A5gment')
Пример #9
0
 def test_path_params(self):
     assert (URLObject.from_iri(u('https://example.com/foo;p\xe5rameter'))
             == 'https://example.com/foo;p%C3%A5rameter')
Пример #10
0
 def test_encode_path(self):
     assert (URLObject.from_iri(u('https://example.com/p\xe5th/path2')) ==
             'https://example.com/p%C3%A5th/path2')
Пример #11
0
 def test_encode_query(self):
     assert (URLObject.from_iri(
         u('https://example.com/?k\xe9y=v\xe5l&key2=val2')) ==
             'https://example.com/?k%C3%A9y=v%C3%A5l&key2=val2')
Пример #12
0
 def test_port_maintained(self):
     assert (URLObject.from_iri(u('https://\xe9xample.com:80/')) ==
             'https://xn--xample-9ua.com:80/')
Пример #13
0
 def test_encode_hostname_idna(self):
     assert (URLObject.from_iri(
         u('https://\xe9xample.com/')) == 'https://xn--xample-9ua.com/')
Пример #14
0
 def setUp(self):
     self.url_string = u(
         "https://github.com/zacharyvoase/urlobject?spam=eggs#foo")
Пример #15
0
 def test_port_maintained(self):
     assert (URLObject.from_iri(u('https://\xe9xample.com:80/')) ==
             'https://xn--xample-9ua.com:80/')
Пример #16
0
 def test_quoted_iri(self):
     """
     If an IRI already has some quoted characters, they will be maintained as is.
     """
     assert (URLObject.from_iri(u('https://example.com/foo%20b\xe5r/')) ==
             'https://example.com/foo%20b%C3%A5r/')
Пример #17
0
 def test_encode_path(self):
     assert (URLObject.from_iri(u('https://example.com/p\xe5th/path2')) ==
             'https://example.com/p%C3%A5th/path2')
Пример #18
0
 def test_quote_other_special_characters(self):
     assert (URLObject.from_iri(u('https://example.com/foo bar/')) ==
             'https://example.com/foo%20bar/')
Пример #19
0
 def test_encode_fragment(self):
     assert (URLObject.from_iri(u('https://example.com/#fr\xe5gment')) ==
             'https://example.com/#fr%C3%A5gment')
Пример #20
0
 def test_join_segments_encodes_non_ascii_and_special_characters_including_slash(
         self):
     assert URLPath.join_segments((
         'a b',
         u('d/\N{LATIN SMALL LETTER E WITH ACUTE}'))) == '/a%20b/d%2F%C3%A9'
Пример #21
0
 def test_quoted_iri(self):
     """
     If an IRI already has some quoted characters, they will be maintained as is.
     """
     assert (URLObject.from_iri(u('https://example.com/foo%20b\xe5r/')) ==
         'https://example.com/foo%20b%C3%A5r/')
Пример #22
0
 def test_add_encodes_non_ascii_and_reserved_characters(self):
     assert URLPath('/a/b/c').add(
         u('d /\N{LATIN SMALL LETTER E WITH ACUTE}')
     ) == '/a/b/c/d%20/%C3%A9'
Пример #23
0
 def test_list_correctly_decodes_utf_8(self):
     assert QueryString('foo=%EF%BF%BD').list == [('foo', u('\ufffd'))]
Пример #24
0
 def test_list_correctly_decodes_utf_8(self):
     assert QueryString("foo=%EF%BF%BD").list == [("foo", u("\ufffd"))]
Пример #25
0
 def setUp(self):
     self.url_string = u("https://github.com/zacharyvoase/urlobject?spam=eggs#foo")
Пример #26
0
 def test_join_segments_encodes_non_ascii_and_special_characters_including_slash(self):
     assert URLPath.join_segments(('a b', u('d/\N{LATIN SMALL LETTER E WITH ACUTE}'))) == '/a%20b/d%2F%C3%A9'