Skip to content

Commit 8ef5aa2

Browse files
committed
using bytes for response body in tests
1 parent 3a03ef7 commit 8ef5aa2

File tree

1 file changed

+5
-8
lines changed

1 file changed

+5
-8
lines changed

tests/test_selector.py

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,6 @@
1-
import re
21
import warnings
32
import weakref
4-
import six
53
from twisted.trial import unittest
6-
from scrapy.exceptions import ScrapyDeprecationWarning
74
from scrapy.http import TextResponse, HtmlResponse, XmlResponse
85
from scrapy.selector import Selector
96
from scrapy.selector.lxmlsel import XmlXPathSelector, HtmlXPathSelector, XPathSelector
@@ -14,7 +11,7 @@ class SelectorTestCase(unittest.TestCase):
1411

1512
def test_simple_selection(self):
1613
"""Simple selector tests"""
17-
body = u"<p><input name='a'value='1'/><input name='b'value='2'/></p>"
14+
body = b"<p><input name='a'value='1'/><input name='b'value='2'/></p>"
1815
response = TextResponse(url="http://example.com", body=body, encoding='utf-8')
1916
sel = Selector(response)
2017

@@ -53,7 +50,7 @@ def test_deprecated_root_argument_ambiguous(self):
5350
self.assertIn('Ignoring deprecated `_root` argument', str(w[-1].message))
5451

5552
def test_flavor_detection(self):
56-
text = u'<div><img src="http://github.com/a.jpg"><p>Hello</div>'
53+
text = b'<div><img src="http://github.com/a.jpg"><p>Hello</div>'
5754
sel = Selector(XmlResponse('http://example.com', body=text, encoding='utf-8'))
5855
self.assertEqual(sel.type, 'xml')
5956
self.assertEqual(sel.xpath("//div").extract(),
@@ -86,7 +83,7 @@ def test_http_header_encoding_precedence(self):
8683
def test_badly_encoded_body(self):
8784
# \xe9 alone isn't valid utf8 sequence
8885
r1 = TextResponse('http://www.example.com', \
89-
body=u'<html><p>an Jos\xe9 de</p><html>', \
86+
body=b'<html><p>an Jos\xe9 de</p><html>', \
9087
encoding='utf-8')
9188
Selector(r1).xpath('//text()').extract()
9289

@@ -100,7 +97,7 @@ def test_weakref_slots(self):
10097

10198
class DeprecatedXpathSelectorTest(unittest.TestCase):
10299

103-
text = u'<div><img src="http://github.com/a.jpg"><p>Hello</div>'
100+
text = '<div><img src="http://github.com/a.jpg"><p>Hello</div>'
104101

105102
def test_warnings_xpathselector(self):
106103
cls = XPathSelector
@@ -178,4 +175,4 @@ class UserClass(cls):
178175
self.assertTrue(isinstance(sel, Selector))
179176
self.assertTrue(isinstance(usel, Selector))
180177
self.assertTrue(isinstance(sel, XPathSelector))
181-
self.assertTrue(isinstance(usel, XPathSelector))
178+
self.assertTrue(isinstance(usel, XPathSelector))

0 commit comments

Comments
 (0)