diff --git a/searx/engines/bing_news.py b/searx/engines/bing_news.py index 0e297581..b999b2a3 100644 --- a/searx/engines/bing_news.py +++ b/searx/engines/bing_news.py @@ -85,7 +85,7 @@ def request(query, params): def response(resp): results = [] - rss = etree.fromstring(resp.text) + rss = etree.fromstring(resp.content) ns = rss.nsmap diff --git a/tests/unit/engines/test_bing_news.py b/tests/unit/engines/test_bing_news.py index 28ec7a3e..1f1aeca1 100644 --- a/tests/unit/engines/test_bing_news.py +++ b/tests/unit/engines/test_bing_news.py @@ -36,10 +36,10 @@ class TestBingNewsEngine(SearxTestCase): self.assertRaises(AttributeError, bing_news.response, '') self.assertRaises(AttributeError, bing_news.response, '[]') - response = mock.Mock(text='') + response = mock.Mock(content='') self.assertEqual(bing_news.response(response), []) - response = mock.Mock(text='') + response = mock.Mock(content='') self.assertEqual(bing_news.response(response), []) html = """ @@ -74,7 +74,7 @@ class TestBingNewsEngine(SearxTestCase): """ # noqa - response = mock.Mock(text=html.encode('utf-8')) + response = mock.Mock(content=html.encode('utf-8')) results = bing_news.response(response) self.assertEqual(type(results), list) self.assertEqual(len(results), 2) @@ -113,7 +113,7 @@ class TestBingNewsEngine(SearxTestCase): """ # noqa - response = mock.Mock(text=html.encode('utf-8')) + response = mock.Mock(content=html.encode('utf-8')) results = bing_news.response(response) self.assertEqual(type(results), list) self.assertEqual(len(results), 1) @@ -136,11 +136,11 @@ class TestBingNewsEngine(SearxTestCase): """ # noqa - response = mock.Mock(text=html.encode('utf-8')) + response = mock.Mock(content=html.encode('utf-8')) results = bing_news.response(response) self.assertEqual(type(results), list) self.assertEqual(len(results), 0) html = """gabarge""" - response = mock.Mock(text=html.encode('utf-8')) + response = mock.Mock(content=html.encode('utf-8')) self.assertRaises(lxml.etree.XMLSyntaxError, bing_news.response, response)