本文整理汇总了Python中linkcheck.models.Url类的典型用法代码示例。如果您正苦于以下问题:Python Url类的具体用法?Python Url怎么用?Python Url使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Url类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_external_check_302_followed
def test_external_check_302_followed(self):
"""
For temporary redirects, we do not report any redirection in `redirect_to`.
"""
uv = Url(url="%s/http/redirect/302/" % self.live_server_url, still_exists=True)
uv.check_url()
self.assertEqual(uv.status, True)
self.assertEqual(uv.message, '200 OK')
self.assertEqual(uv.redirect_to, '')
示例2: test_internal_check_view_redirect
def test_internal_check_view_redirect(self):
uv = Url(url="/admin/linkcheck", still_exists=True)
uv.check_url()
self.assertEqual(uv.status, True)
self.assertEqual(uv.message, 'This link redirects: code 301 (Working redirect)')
uv = Url(url="/http/brokenredirect/", still_exists=True)
uv.check_url()
self.assertEqual(uv.status, False)
redirect_code = 301 if django.VERSION < (1, 9) else 302
self.assertEqual(uv.message, 'This link redirects: code %d (Broken redirect)' % redirect_code)
示例3: test_external_check_200_utf8
def test_external_check_200_utf8(self):
uv = Url(url="%s/http/200/r%%C3%%BCckmeldung/" % self.live_server_url, still_exists=True)
uv.check_url()
self.assertEqual(uv.status, True)
self.assertEqual(uv.message, '200 OK')
# Also when the url is not encoded
uv = Url(url="%s/http/200/rückmeldung/" % self.live_server_url, still_exists=True)
uv.check_url()
self.assertEqual(uv.status, True)
self.assertEqual(uv.message, '200 OK')
示例4: test_internal_check_media_utf8
def test_internal_check_media_utf8(self):
uv = Url(url="/media/r%C3%BCckmeldung", still_exists=True)
uv.check_url()
self.assertEqual(uv.status, True)
self.assertEqual(uv.message, 'Working file link')
# Also when the url is not encoded
uv = Url(url="/media/rückmeldung", still_exists=True)
uv.check_url()
self.assertEqual(uv.status, True)
self.assertEqual(uv.message, 'Working file link')
示例5: test_internal_check_media_utf8
def test_internal_check_media_utf8(self):
media_file = os.path.join(os.path.dirname(__file__), 'media', 'rückmeldung')
open(media_file, 'a').close()
self.addCleanup(os.remove, media_file)
uv = Url(url="/media/r%C3%BCckmeldung", still_exists=True)
uv.check_url()
self.assertEqual(uv.status, True)
self.assertEqual(uv.message, 'Working file link')
# Also when the url is not encoded
uv = Url(url="/media/rückmeldung", still_exists=True)
uv.check_url()
self.assertEqual(uv.status, True)
self.assertEqual(uv.message, 'Working file link')
示例6: test_external_check_404
def test_external_check_404(self):
uv = Url(url="http://qa-dev.w3.org/link-testsuite/http.php?code=404", still_exists=True)
uv.check()
self.assertEquals(uv.status, False)
self.assertEquals(uv.message, '404 Not Found')
示例7: test_external_check_301
def test_external_check_301(self):
uv = Url(url="http://qa-dev.w3.org/link-testsuite/http.php?code=301", still_exists=True)
uv.check()
self.assertEquals(uv.status, False)
self.assertEquals(uv.message, '301 Moved Permanently')
示例8: test_external_check_200
def test_external_check_200(self):
uv = Url(url="http://qa-dev.w3.org/link-testsuite/http.php?code=200", still_exists=True)
uv.check()
self.assertEquals(uv.status, True)
self.assertEquals(uv.message, '200 OK')
示例9: test_internal_check_media_utf8
def test_internal_check_media_utf8(self):
uv = Url(url="/media/r%C3%BCckmeldung", still_exists=True)
uv.check()
self.assertEquals(uv.status, True)
self.assertEquals(uv.message, 'Working file link')
示例10: test_internal_check_broken_internal_link
def test_internal_check_broken_internal_link(self):
uv = Url(url="/broken/internal/link", still_exists=True)
uv.check()
self.assertEquals(uv.status, False)
self.assertEquals(uv.message, 'Broken internal link')
示例11: test_internal_check_anchor
def test_internal_check_anchor(self):
uv = Url(url="#some_anchor", still_exists=True)
uv.check()
self.assertEquals(uv.status, None)
self.assertEquals(uv.message, 'Link to within the same page (not automatically checked)')
示例12: test_external_check_404
def test_external_check_404(self):
uv = Url(url="%s/whatever/" % self.live_server_url, still_exists=True)
uv.check_url()
self.assertEqual(uv.status, False)
self.assertEqual(uv.message.lower(), '404 not found')
示例13: test_external_check_301_followed
def test_external_check_301_followed(self):
uv = Url(url="%s/http/redirect/301/" % self.live_server_url, still_exists=True)
uv.check_url()
self.assertEqual(uv.status, True)
self.assertEqual(uv.message, '301 OK')
self.assertEqual(uv.redirect_to, '%s/http/200/' % self.live_server_url)
示例14: test_external_check_301
def test_external_check_301(self):
uv = Url(url="%s/http/301/" % self.live_server_url, still_exists=True)
uv.check_url()
self.assertEqual(uv.status, False)
self.assertEqual(uv.message.lower(), '301 moved permanently')
示例15: test_external_check_200
def test_external_check_200(self):
uv = Url(url="%s/http/200/" % self.live_server_url, still_exists=True)
uv.check_url()
self.assertEqual(uv.status, True)
self.assertEqual(uv.message, '200 OK')
self.assertEqual(uv.redirect_to, '')