From 179c4588ca12d363ab8ce9d2badad6c456d353a9 Mon Sep 17 00:00:00 2001 From: Elias Dorneles Date: Thu, 10 Sep 2015 19:36:47 -0300 Subject: [PATCH] adding test for latin1 location --- tests/test_downloadermiddleware_redirect.py | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/tests/test_downloadermiddleware_redirect.py b/tests/test_downloadermiddleware_redirect.py index 15e1dff37..11d9fd152 100644 --- a/tests/test_downloadermiddleware_redirect.py +++ b/tests/test_downloadermiddleware_redirect.py @@ -1,3 +1,5 @@ +# -*- coding: utf-8 -*- + import unittest from scrapy.downloadermiddlewares.redirect import RedirectMiddleware, MetaRefreshMiddleware @@ -150,6 +152,14 @@ class RedirectMiddlewareTest(unittest.TestCase): [404, 301, 302]})) _test_passthrough(Request(url, meta={'handle_httpstatus_all': True})) + def test_latin1_location(self): + req = Request('http://scrapytest.org/first') + latin1_path = u'/ação'.encode('latin1') + resp = Response('http://scrapytest.org/first', headers={'Location': latin1_path}, status=302) + req_result = self.mw.process_response(req, resp, self.spider) + perc_encoded_utf8_url = 'http://scrapytest.org/a%C3%A7%C3%A3o' + self.assertEquals(perc_encoded_utf8_url, req_result.url) + class MetaRefreshMiddlewareTest(unittest.TestCase):