From 8ef5aa2ffce4b2b8955b58b532920098f6fe8ea4 Mon Sep 17 00:00:00 2001 From: Elias Dorneles Date: Tue, 11 Aug 2015 13:58:53 -0300 Subject: [PATCH] using bytes for response body in tests --- tests/test_selector.py | 13 +++++-------- 1 file changed, 5 insertions(+), 8 deletions(-) diff --git a/tests/test_selector.py b/tests/test_selector.py index 4806bb90b..2d6d8c439 100644 --- a/tests/test_selector.py +++ b/tests/test_selector.py @@ -1,9 +1,6 @@ -import re import warnings import weakref -import six from twisted.trial import unittest -from scrapy.exceptions import ScrapyDeprecationWarning from scrapy.http import TextResponse, HtmlResponse, XmlResponse from scrapy.selector import Selector from scrapy.selector.lxmlsel import XmlXPathSelector, HtmlXPathSelector, XPathSelector @@ -14,7 +11,7 @@ class SelectorTestCase(unittest.TestCase): def test_simple_selection(self): """Simple selector tests""" - body = u"

" + body = b"

" response = TextResponse(url="http://example.com", body=body, encoding='utf-8') sel = Selector(response) @@ -53,7 +50,7 @@ class SelectorTestCase(unittest.TestCase): self.assertIn('Ignoring deprecated `_root` argument', str(w[-1].message)) def test_flavor_detection(self): - text = u'

Hello

' + text = b'

Hello

' sel = Selector(XmlResponse('http://example.com', body=text, encoding='utf-8')) self.assertEqual(sel.type, 'xml') self.assertEqual(sel.xpath("//div").extract(), @@ -86,7 +83,7 @@ class SelectorTestCase(unittest.TestCase): def test_badly_encoded_body(self): # \xe9 alone isn't valid utf8 sequence r1 = TextResponse('http://www.example.com', \ - body=u'

an Jos\xe9 de

', \ + body=b'

an Jos\xe9 de

', \ encoding='utf-8') Selector(r1).xpath('//text()').extract() @@ -100,7 +97,7 @@ class SelectorTestCase(unittest.TestCase): class DeprecatedXpathSelectorTest(unittest.TestCase): - text = u'

Hello

' + text = '

Hello

' def test_warnings_xpathselector(self): cls = XPathSelector @@ -178,4 +175,4 @@ class DeprecatedXpathSelectorTest(unittest.TestCase): self.assertTrue(isinstance(sel, Selector)) self.assertTrue(isinstance(usel, Selector)) self.assertTrue(isinstance(sel, XPathSelector)) - self.assertTrue(isinstance(usel, XPathSelector)) \ No newline at end of file + self.assertTrue(isinstance(usel, XPathSelector))