From daabc718a9e63556b5aa9ae7e92bb0fc4cb7604f Mon Sep 17 00:00:00 2001 From: Nikolaos-Digenis Karagiannis Date: Wed, 2 Jul 2014 16:03:21 +0300 Subject: [PATCH 1/4] selector.__repr__ test --- scrapy/tests/test_selector.py | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/scrapy/tests/test_selector.py b/scrapy/tests/test_selector.py index d60521cbc5c..00790537bca 100644 --- a/scrapy/tests/test_selector.py +++ b/scrapy/tests/test_selector.py @@ -36,6 +36,16 @@ def test_simple_selection(self): self.assertEqual([x.extract() for x in sel.xpath("concat(//input[@name='a']/@value, //input[@name='b']/@value)")], [u'12']) + def test_representation(self): + body = u"

".format(50 * 'b') + response = TextResponse(url="http://example.com", body=body, encoding='utf8') + sel = self.sscls(response) + + self.assertEqual( + map(repr, sel.xpath('//input/@name')), + [u"".format(40 * 'b')] + ) + def test_select_unicode_query(self): body = u"

" response = TextResponse(url="http://example.com", body=body, encoding='utf8') From d2d014a4e90640b5bef8e3ba239d445fa502028b Mon Sep 17 00:00:00 2001 From: Nikolaos-Digenis Karagiannis Date: Thu, 3 Jul 2014 09:32:52 +0300 Subject: [PATCH 2/4] selector.__repr__ test, repr type is bytesarray --- scrapy/tests/test_selector.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scrapy/tests/test_selector.py b/scrapy/tests/test_selector.py index 00790537bca..9533bfbd24a 100644 --- a/scrapy/tests/test_selector.py +++ b/scrapy/tests/test_selector.py @@ -43,7 +43,7 @@ def test_representation(self): self.assertEqual( map(repr, sel.xpath('//input/@name')), - [u"".format(40 * 'b')] + ["".format(40 * 'b')] ) def test_select_unicode_query(self): From 9ac639abd323793999bae41bf43fbe1ba08bb2c4 Mon Sep 17 00:00:00 2001 From: Nikolaos-Digenis Karagiannis Date: Thu, 3 Jul 2014 13:04:37 +0300 Subject: [PATCH 3/4] selector.__repr__ test, rename method --- scrapy/tests/test_selector.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scrapy/tests/test_selector.py b/scrapy/tests/test_selector.py index 9533bfbd24a..97639d26934 100644 --- a/scrapy/tests/test_selector.py +++ b/scrapy/tests/test_selector.py @@ -36,7 +36,7 @@ def test_simple_selection(self): self.assertEqual([x.extract() for x in sel.xpath("concat(//input[@name='a']/@value, //input[@name='b']/@value)")], [u'12']) - def test_representation(self): + def test_representation_slice(self): body = u"

".format(50 * 'b') response = TextResponse(url="http://example.com", body=body, encoding='utf8') sel = self.sscls(response) From aacf1d05e17888c9f0017d7b5d6ee74fe01aed4c Mon Sep 17 00:00:00 2001 From: Nikolaos-Digenis Karagiannis Date: Thu, 3 Jul 2014 13:05:20 +0300 Subject: [PATCH 4/4] selector.__repr__ test, unicode query --- scrapy/tests/test_selector.py | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/scrapy/tests/test_selector.py b/scrapy/tests/test_selector.py index 97639d26934..6fbb451a652 100644 --- a/scrapy/tests/test_selector.py +++ b/scrapy/tests/test_selector.py @@ -46,6 +46,15 @@ def test_representation_slice(self): ["".format(40 * 'b')] ) + def test_representation_unicode_query(self): + body = u"

".format(50 * 'b') + response = TextResponse(url="http://example.com", body=body, encoding='utf8') + sel = self.sscls(response) + self.assertEqual( + map(repr, sel.xpath(u'//input[@value="\xa9"]/@value')), + [""] + ) + def test_select_unicode_query(self): body = u"

" response = TextResponse(url="http://example.com", body=body, encoding='utf8')