summaryrefslogtreecommitdiff
path: root/searx/engines/yahoo.py
diff options
context:
space:
mode:
authormarc <a01200356@itesm.mx>2016-12-15 00:34:43 -0600
committermarc <a01200356@itesm.mx>2016-12-15 00:40:21 -0600
commitaf35eee10b98940c51c6e5e18629de514b4bd48d (patch)
tree804b0a4cfe08bb897541e9e8571b921a78e07992 /searx/engines/yahoo.py
parente0c270bd72f7b2a40222e3ed264e25d36cb0fc30 (diff)
downloadsearxng-af35eee10b98940c51c6e5e18629de514b4bd48d.tar.gz
searxng-af35eee10b98940c51c6e5e18629de514b4bd48d.zip
tests for _fetch_supported_languages in engines
and refactor method to make it testable without making requests
Diffstat (limited to 'searx/engines/yahoo.py')
-rw-r--r--searx/engines/yahoo.py8
1 files changed, 3 insertions, 5 deletions
diff --git a/searx/engines/yahoo.py b/searx/engines/yahoo.py
index db10c8939..5c62c2ed8 100644
--- a/searx/engines/yahoo.py
+++ b/searx/engines/yahoo.py
@@ -14,7 +14,6 @@
from urllib import urlencode
from urlparse import unquote
from lxml import html
-from requests import get
from searx.engines.xpath import extract_text, extract_url
# engine dependent config
@@ -144,13 +143,12 @@ def response(resp):
# get supported languages from their site
-def fetch_supported_languages():
+def _fetch_supported_languages(resp):
supported_languages = []
- response = get(supported_languages_url)
- dom = html.fromstring(response.text)
+ dom = html.fromstring(resp.text)
options = dom.xpath('//div[@id="yschlang"]/span/label/input')
for option in options:
- code = option.xpath('./@value')[0][5:]
+ code = option.xpath('./@value')[0][5:].replace('_', '-')
supported_languages.append(code)
return supported_languages