Пример #1
0
    def test_join(self):
        """Test basic joins"""

        base_url = 'http://example.com/'
        base_url_alt = 'http://example.com'
        path0 = 'owner'
        path1 = 'repository'
        path2 = '/owner/repository'
        path3 = 'issues/8'

        url = urljoin(base_url, path0, path1)
        self.assertEqual(url, 'http://example.com/owner/repository')

        url = urljoin(base_url, path2)
        self.assertEqual(url, 'http://example.com/owner/repository')

        url = urljoin(base_url, path0, path1, path3)
        self.assertEqual(url, 'http://example.com/owner/repository/issues/8')

        url = urljoin(base_url_alt, path0, path1)
        self.assertEqual(url, 'http://example.com/owner/repository')
Пример #2
0
    def test_join(self):
        """Test basic joins"""

        base_url = 'http://example.com/'
        base_url_alt = 'http://example.com'
        path0 = 'owner'
        path1 = 'repository'
        path2 = '/owner/repository'
        path3 = 'issues/8'

        url = urljoin(base_url, path0, path1)
        self.assertEqual(url, 'http://example.com/owner/repository')

        url = urljoin(base_url, path2)
        self.assertEqual(url, 'http://example.com/owner/repository')

        url = urljoin(base_url, path0, path1, path3)
        self.assertEqual(url, 'http://example.com/owner/repository/issues/8')

        url = urljoin(base_url_alt, path0, path1)
        self.assertEqual(url, 'http://example.com/owner/repository')