Skip to content

Commit

Permalink
Merge pull request scrapy#779 from Digenis/master
Browse files Browse the repository at this point in the history
selector.__repr__ test
  • Loading branch information
kmike committed Jul 3, 2014
2 parents 36d99a0 + aacf1d0 commit a653bf3
Showing 1 changed file with 19 additions and 0 deletions.
19 changes: 19 additions & 0 deletions scrapy/tests/test_selector.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,25 @@ 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_slice(self):
body = u"<p><input name='{}' value='\xa9'/></p>".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')),
["<Selector xpath='//input/@name' data=u'{}'>".format(40 * 'b')]
)

def test_representation_unicode_query(self):
body = u"<p><input name='{}' value='\xa9'/></p>".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')),
["<Selector xpath=u'//input[@value=\"\\xa9\"]/@value' data=u'\\xa9'>"]
)

def test_select_unicode_query(self):
body = u"<p><input name='\xa9' value='1'/></p>"
response = TextResponse(url="http://example.com", body=body, encoding='utf8')
Expand Down

0 comments on commit a653bf3

Please sign in to comment.