Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit e9ba2366 authored by Nicolas Gelot's avatar Nicolas Gelot
Browse files

Revert wrong encoding changes

This patch reverts some wrong changes about
encoding from 2cc4bf3e.
parent c57f0c73
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -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

+1 −1
Original line number Diff line number Diff line
@@ -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):
+6 −6
Original line number Diff line number Diff line
@@ -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&amp;setmkt=en-US&amp;first=1&amp;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&amp;setmkt=en-US&amp;first=1&amp;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&amp;setmkt=en-US&amp;first=1&amp;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)
+3 −3
Original line number Diff line number Diff line
@@ -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'