mirror of
https://github.com/scrapy/scrapy.git
synced 2025-02-23 23:23:44 +00:00
- change ``failIf`` to ``assertFalse`` - change ``asertEquals`` to ``assertEqual`` - change ``assert_`` to ``assertTrue`` https://docs.python.org/2/library/unittest.html#deprecated-aliases
22 lines
678 B
Python
22 lines
678 B
Python
from unittest import TestCase
|
|
|
|
from scrapy.spidermiddlewares.urllength import UrlLengthMiddleware
|
|
from scrapy.http import Response, Request
|
|
from scrapy.spiders import Spider
|
|
|
|
|
|
class TestUrlLengthMiddleware(TestCase):
|
|
|
|
def test_process_spider_output(self):
|
|
res = Response('http://scrapytest.org')
|
|
|
|
short_url_req = Request('http://scrapytest.org/')
|
|
long_url_req = Request('http://scrapytest.org/this_is_a_long_url')
|
|
reqs = [short_url_req, long_url_req]
|
|
|
|
mw = UrlLengthMiddleware(maxlength=25)
|
|
spider = Spider('foo')
|
|
out = list(mw.process_spider_output(res, reqs, spider))
|
|
self.assertEqual(out, [short_url_req])
|
|
|