File tree Expand file tree Collapse file tree 3 files changed +13
-3
lines changed Expand file tree Collapse file tree 3 files changed +13
-3
lines changed Original file line number Diff line number Diff line change 1
1
language : python
2
2
python :
3
3
- " 2.7"
4
+ - " 3.2"
4
5
- " 3.6"
6
+ # 3.2 added because https://github.com/aviaryan/python-gsearch/issues/3
5
7
# command to run tests
6
8
script : python -m unittest tests.tests
Original file line number Diff line number Diff line change 11
11
# Python 3
12
12
from urllib import request
13
13
from html .parser import HTMLParser # keep it to avoid warning
14
- from html import unescape
15
14
from urllib .parse import quote , unquote
16
15
# local
17
16
try :
18
17
from gsearch .data import user_agents # works in tests
19
18
except ImportError :
20
19
from data import user_agents # works in a normal run
20
+ try :
21
+ from html import unescape # Python 3.4+
22
+ except ImportError :
23
+ pass
21
24
except ImportError :
22
25
# Python 2
23
26
import urllib2 as request
@@ -86,7 +89,12 @@ def convert_unicode(text):
86
89
h = HTMLParser ()
87
90
s = h .unescape (text )
88
91
else :
89
- s = unescape (text )
92
+ try :
93
+ s = unescape (text )
94
+ except Exception :
95
+ # Python 3.3 and below
96
+ # https://stackoverflow.com/a/2360639/2295672
97
+ s = HTMLParser ().unescape (text )
90
98
return s
91
99
92
100
Original file line number Diff line number Diff line change @@ -17,7 +17,7 @@ def test_results_count(self):
17
17
self .assertTrue (len (res ) > 10 , 'Less than 11 results returned' )
18
18
19
19
def test_results_zero (self ):
20
- res = search ('dsjaksfajsdhkhawkehkajdwek' )
20
+ res = search ('dsjaksfajsdhkhawkehkajdwek' + ( str ( randint ( 10 , 100 )) * 5 ) )
21
21
self .assertTrue (len (res ) == 0 , 'There was a result. What has this world come to?' )
22
22
23
23
def test_unicode (self ):
You can’t perform that action at this time.
0 commit comments