mirror of https://github.com/scrapy/scrapy.git
refactor: Use `safe_url_string` to standardize url output
This commit is contained in:
parent
1289422284
commit
582a6bf6db
|
|
@ -22,8 +22,7 @@ from scrapy.spiders import (
|
|||
from scrapy.linkextractors import LinkExtractor
|
||||
from scrapy.utils.test import get_crawler
|
||||
from tests import get_testdata
|
||||
from pkg_resources import parse_version
|
||||
from w3lib import __version__ as w3lib_version
|
||||
from w3lib.url import safe_url_string
|
||||
|
||||
|
||||
class SpiderTest(unittest.TestCase):
|
||||
|
|
@ -362,12 +361,10 @@ class CrawlSpiderTest(SpiderTest):
|
|||
output = list(spider._requests_to_follow(response))
|
||||
self.assertEqual(len(output), 3)
|
||||
self.assertTrue(all(map(lambda r: isinstance(r, Request), output)))
|
||||
urls = ['http://EXAMPLE.ORG/SOMEPAGE/ITEM/12.HTML',
|
||||
'http://EXAMPLE.ORG/ABOUT.HTML',
|
||||
'http://EXAMPLE.ORG/NOFOLLOW.HTML']
|
||||
if parse_version(w3lib_version) >= parse_version('2.0.0'):
|
||||
urls = list(map(lambda u: u.replace("EXAMPLE.ORG", "example.org"), urls))
|
||||
self.assertEqual([r.url for r in output], urls)
|
||||
self.assertEqual([r.url for r in output],
|
||||
[safe_url_string('http://EXAMPLE.ORG/SOMEPAGE/ITEM/12.HTML'),
|
||||
safe_url_string('http://EXAMPLE.ORG/ABOUT.HTML'),
|
||||
safe_url_string('http://EXAMPLE.ORG/NOFOLLOW.HTML')])
|
||||
|
||||
def test_process_request_instance_method_with_response(self):
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue