1
- import re
2
1
import warnings
3
2
import weakref
4
- import six
5
3
from twisted .trial import unittest
6
- from scrapy .exceptions import ScrapyDeprecationWarning
7
4
from scrapy .http import TextResponse , HtmlResponse , XmlResponse
8
5
from scrapy .selector import Selector
9
6
from scrapy .selector .lxmlsel import XmlXPathSelector , HtmlXPathSelector , XPathSelector
@@ -14,7 +11,7 @@ class SelectorTestCase(unittest.TestCase):
14
11
15
12
def test_simple_selection (self ):
16
13
"""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>"
18
15
response = TextResponse (url = "http://example.com" , body = body , encoding = 'utf-8' )
19
16
sel = Selector (response )
20
17
@@ -53,7 +50,7 @@ def test_deprecated_root_argument_ambiguous(self):
53
50
self .assertIn ('Ignoring deprecated `_root` argument' , str (w [- 1 ].message ))
54
51
55
52
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>'
57
54
sel = Selector (XmlResponse ('http://example.com' , body = text , encoding = 'utf-8' ))
58
55
self .assertEqual (sel .type , 'xml' )
59
56
self .assertEqual (sel .xpath ("//div" ).extract (),
@@ -86,7 +83,7 @@ def test_http_header_encoding_precedence(self):
86
83
def test_badly_encoded_body (self ):
87
84
# \xe9 alone isn't valid utf8 sequence
88
85
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>' , \
90
87
encoding = 'utf-8' )
91
88
Selector (r1 ).xpath ('//text()' ).extract ()
92
89
@@ -100,7 +97,7 @@ def test_weakref_slots(self):
100
97
101
98
class DeprecatedXpathSelectorTest (unittest .TestCase ):
102
99
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>'
104
101
105
102
def test_warnings_xpathselector (self ):
106
103
cls = XPathSelector
@@ -178,4 +175,4 @@ class UserClass(cls):
178
175
self .assertTrue (isinstance (sel , Selector ))
179
176
self .assertTrue (isinstance (usel , Selector ))
180
177
self .assertTrue (isinstance (sel , XPathSelector ))
181
- self .assertTrue (isinstance (usel , XPathSelector ))
178
+ self .assertTrue (isinstance (usel , XPathSelector ))
0 commit comments