示例#1
0
 def test_url_join(self):
     self.assertEqual(
         'http://example.net',
         urljoin('http://example.com', '//example.net')
     )
     self.assertEqual(
         'https://example.net',
         urljoin('https://example.com', '//example.net')
     )
     self.assertEqual(
         'https://example.com/asdf',
         urljoin('https://example.com/cookies', '/asdf')
     )
     self.assertEqual(
         'http://example.com/asdf',
         urljoin('http://example.com/cookies', 'asdf')
     )
     self.assertEqual(
         'http://example.com/cookies/asdf',
         urljoin('http://example.com/cookies/', 'asdf')
     )
     self.assertEqual(
         'https://example.net/asdf',
         urljoin('https://example.net/', '/asdf')
     )
     self.assertEqual(
         'http://example.net/asdf',
         urljoin('https://example.com', 'http://example.net/asdf')
     )
     self.assertEqual(
         'http://example.com/',
         urljoin('http://example.com', '//example.com/')
     )
示例#2
0
 def test_url_join(self):
     self.assertEqual('http://example.net',
                      urljoin('http://example.com', '//example.net'))
     self.assertEqual('https://example.net',
                      urljoin('https://example.com', '//example.net'))
     self.assertEqual('https://example.com/asdf',
                      urljoin('https://example.com/cookies', '/asdf'))
     self.assertEqual('http://example.com/asdf',
                      urljoin('http://example.com/cookies', 'asdf'))
     self.assertEqual('http://example.com/cookies/asdf',
                      urljoin('http://example.com/cookies/', 'asdf'))
     self.assertEqual('https://example.net/asdf',
                      urljoin('https://example.net/', '/asdf'))
     self.assertEqual(
         'http://example.net/asdf',
         urljoin('https://example.com', 'http://example.net/asdf'))
     self.assertEqual('http://example.com/',
                      urljoin('http://example.com', '//example.com/'))
     self.assertEqual('http://example.com/a/style.css',
                      urljoin('http://example.com/a/', './style.css'))
     self.assertEqual('http://example.com/style.css',
                      urljoin('http://example.com/a/', './../style.css'))
示例#3
0
文件: url_test.py 项目: d235j/wpull
 def test_url_join(self):
     self.assertEqual('http://example.net',
                      urljoin('http://example.com', '//example.net'))
     self.assertEqual('https://example.net',
                      urljoin('https://example.com', '//example.net'))
     self.assertEqual('http://example.net',
                      urljoin('http://example.com/', '//example.net'))
     self.assertEqual('https://example.net',
                      urljoin('https://example.com/', '//example.net'))
     self.assertEqual('http://example.net/',
                      urljoin('http://example.com/', '//example.net/'))
     self.assertEqual('https://example.net/',
                      urljoin('https://example.com/', '//example.net/'))
     self.assertEqual('https://example.com/asdf',
                      urljoin('https://example.com/cookies', '/asdf'))
     self.assertEqual('http://example.com/asdf',
                      urljoin('http://example.com/cookies', 'asdf'))
     self.assertEqual('http://example.com/cookies/asdf',
                      urljoin('http://example.com/cookies/', 'asdf'))
     self.assertEqual('https://example.net/asdf',
                      urljoin('https://example.net/', '/asdf'))
     self.assertEqual(
         'http://example.net/asdf',
         urljoin('https://example.com', 'http://example.net/asdf'))
     self.assertEqual('http://example.com/',
                      urljoin('http://example.com', '//example.com/'))
     self.assertEqual('http://example.com/',
                      urljoin('http://example.com/', '//'))
     self.assertEqual('http://example.com/',
                      urljoin('http://example.com/', '///'))
     self.assertEqual('http://example.com/a/style.css',
                      urljoin('http://example.com/a/', './style.css'))
     self.assertEqual('http://example.com/style.css',
                      urljoin('http://example.com/a/', './../style.css'))
     self.assertEqual('sausage', urljoin('mailto:hotdogbun', 'sausage'))
     self.assertEqual('mailto://sausage',
                      urljoin('mailto:hotdogbun', '//sausage'))
     self.assertEqual('hotdogbun://sausage',
                      urljoin('hotdogbun', '//sausage'))
示例#4
0
 def test_url_join(self):
     self.assertEqual(
         'http://example.net',
         urljoin('http://example.com', '//example.net')
     )
     self.assertEqual(
         'https://example.net',
         urljoin('https://example.com', '//example.net')
     )
     self.assertEqual(
         'http://example.net',
         urljoin('http://example.com/', '//example.net')
     )
     self.assertEqual(
         'https://example.net',
         urljoin('https://example.com/', '//example.net')
     )
     self.assertEqual(
         'http://example.net/',
         urljoin('http://example.com/', '//example.net/')
     )
     self.assertEqual(
         'https://example.net/',
         urljoin('https://example.com/', '//example.net/')
     )
     self.assertEqual(
         'https://example.com/asdf',
         urljoin('https://example.com/cookies', '/asdf')
     )
     self.assertEqual(
         'http://example.com/asdf',
         urljoin('http://example.com/cookies', 'asdf')
     )
     self.assertEqual(
         'http://example.com/cookies/asdf',
         urljoin('http://example.com/cookies/', 'asdf')
     )
     self.assertEqual(
         'https://example.net/asdf',
         urljoin('https://example.net/', '/asdf')
     )
     self.assertEqual(
         'http://example.net/asdf',
         urljoin('https://example.com', 'http://example.net/asdf')
     )
     self.assertEqual(
         'http://example.com/',
         urljoin('http://example.com', '//example.com/')
     )
     self.assertEqual(
         'http://example.com/',
         urljoin('http://example.com/', '//')
     )
     self.assertEqual(
         'http://example.com/',
         urljoin('http://example.com/', '///')
     )
     self.assertEqual(
         'http://example.com/a/style.css',
         urljoin('http://example.com/a/', './style.css')
     )
     self.assertEqual(
         'http://example.com/style.css',
         urljoin('http://example.com/a/', './../style.css')
     )
     self.assertEqual(
         'sausage',
         urljoin('mailto:hotdogbun', 'sausage')
     )
     self.assertEqual(
         'mailto://sausage',
         urljoin('mailto:hotdogbun', '//sausage')
     )
     self.assertEqual(
         'hotdogbun://sausage',
         urljoin('hotdogbun', '//sausage')
     )