Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in / Register
Toggle navigation
Menu
Open sidebar
e
infra
spot
Commits
ff600724
Commit
ff600724
authored
Jan 11, 2019
by
Gaël Duval
🏄🏼
Browse files
Merge branch 'nicofonk/fix-encoding' into 'master'
Revert wrong encoding changes See merge request e/cloud/my-spot!23
parents
c57f0c73
e9ba2366
Changes
4
Hide whitespace changes
Inline
Side-by-side
searx/engines/bing_news.py
View file @
ff600724
...
...
@@ -82,7 +82,7 @@ def request(query, params):
def
response
(
resp
):
results
=
[]
rss
=
etree
.
fromstring
(
resp
.
content
.
encode
()
)
rss
=
etree
.
fromstring
(
resp
.
content
)
ns
=
rss
.
nsmap
...
...
searx/engines/wolframalpha_api.py
View file @
ff600724
...
...
@@ -65,7 +65,7 @@ def replace_pua_chars(text):
def
response
(
resp
):
results
=
[]
search_results
=
etree
.
XML
(
resp
.
text
.
encode
()
)
search_results
=
etree
.
XML
(
resp
.
text
)
# return empty array if there are no results
if
search_results
.
xpath
(
failure_xpath
):
...
...
tests/unit/engines/test_bing_news.py
View file @
ff600724
...
...
@@ -33,13 +33,13 @@ class TestBingNewsEngine(TestCase):
self
.
assertRaises
(
AttributeError
,
bing_news
.
response
,
''
)
self
.
assertRaises
(
AttributeError
,
bing_news
.
response
,
'[]'
)
response
=
mock
.
Mock
(
content
=
'<html></html>'
)
response
=
mock
.
Mock
(
content
=
b
'<html></html>'
)
self
.
assertEqual
(
bing_news
.
response
(
response
),
[])
response
=
mock
.
Mock
(
content
=
'<html></html>'
)
response
=
mock
.
Mock
(
content
=
b
'<html></html>'
)
self
.
assertEqual
(
bing_news
.
response
(
response
),
[])
html
=
"""<?xml version="1.0" encoding="utf-8" ?>
html
=
b
"""<?xml version="1.0" encoding="utf-8" ?>
<rss version="2.0" xmlns:News="https://www.bing.com:443/news/search?q=python&setmkt=en-US&first=1&format=RSS">
<channel>
<title>python - Bing News</title>
...
...
@@ -84,7 +84,7 @@ class TestBingNewsEngine(TestCase):
self
.
assertEqual
(
results
[
1
][
'content'
],
'Another Article Content'
)
self
.
assertNotIn
(
'img_src'
,
results
[
1
])
html
=
"""<?xml version="1.0" encoding="utf-8" ?>
html
=
b
"""<?xml version="1.0" encoding="utf-8" ?>
<rss version="2.0" xmlns:News="https://www.bing.com:443/news/search?q=python&setmkt=en-US&first=1&format=RSS">
<channel>
<title>python - Bing News</title>
...
...
@@ -119,7 +119,7 @@ class TestBingNewsEngine(TestCase):
self
.
assertEqual
(
results
[
0
][
'content'
],
'Article Content'
)
self
.
assertEqual
(
results
[
0
][
'img_src'
],
'http://another.bing.com/image'
)
html
=
"""<?xml version="1.0" encoding="utf-8" ?>
html
=
b
"""<?xml version="1.0" encoding="utf-8" ?>
<rss version="2.0" xmlns:News="https://www.bing.com:443/news/search?q=python&setmkt=en-US&first=1&format=RSS">
<channel>
<title>python - Bing News</title>
...
...
@@ -138,6 +138,6 @@ class TestBingNewsEngine(TestCase):
self
.
assertEqual
(
type
(
results
),
list
)
self
.
assertEqual
(
len
(
results
),
0
)
html
=
"""<?xml version="1.0" encoding="utf-8" ?>gabarge"""
html
=
b
"""<?xml version="1.0" encoding="utf-8" ?>gabarge"""
response
=
mock
.
Mock
(
content
=
html
)
self
.
assertRaises
(
lxml
.
etree
.
XMLSyntaxError
,
bing_news
.
response
,
response
)
tests/unit/engines/test_wolframalpha_api.py
View file @
ff600724
...
...
@@ -32,14 +32,14 @@ class TestWolframAlphaAPIEngine(TestCase):
request
=
Request
(
headers
=
{
'Referer'
:
referer_url
})
# test failure
xml
=
'''<?xml version='1.0' encoding='UTF-8'?>
xml
=
b
'''<?xml version='1.0' encoding='UTF-8'?>
<queryresult success='false' error='false' />
'''
response
=
mock
.
Mock
(
text
=
xml
)
self
.
assertEqual
(
wolframalpha_api
.
response
(
response
),
[])
# test basic case
xml
=
"""<?xml version='1.0' encoding='UTF-8'?>
xml
=
b
"""<?xml version='1.0' encoding='UTF-8'?>
<queryresult success='true'
error='false'
numpods='3'
...
...
@@ -107,7 +107,7 @@ class TestWolframAlphaAPIEngine(TestCase):
self
.
assertIn
(
'result_plaintext'
,
results
[
1
][
'content'
])
# test calc
xml
=
"""<?xml version='1.0' encoding='UTF-8'?>
xml
=
b
"""<?xml version='1.0' encoding='UTF-8'?>
<queryresult success='true'
error='false'
numpods='2'
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment