fix gettitle errors

This will cause errors in gettitle, such as an HTTP 405 Method Not
Allowed response, to not send out an ugly exception. This was a bug that
got introduced due to the switch to requests.
master
mutantmonkey 2013-11-28 23:28:11 -08:00
parent 26f37e83be
commit 8fa37b3056
2 changed files with 10 additions and 1 deletions

View File

@ -152,7 +152,7 @@ def gettitle(phenny, uri):
#bytes = u.read(262144) #bytes = u.read(262144)
#u.close() #u.close()
except web.ConnectionError: except:
return return
m = r_title.search(bytes) m = r_title.search(bytes)

View File

@ -49,3 +49,12 @@ class TestHead(unittest.TestCase):
snarfuri(self.phenny, input) snarfuri(self.phenny, input)
self.phenny.msg.assert_called_once_with('#phenny', "[ Google ]") self.phenny.msg.assert_called_once_with('#phenny', "[ Google ]")
def test_snarfuri_405(self):
self.phenny.config.prefix = '.'
self.phenny.config.linx_api_key = ""
input = Mock(group=lambda x=0: 'http://ozuma.sakura.ne.jp/httpstatus/405',
sender='#phenny')
snarfuri(self.phenny, input)
self.assertEqual(self.phenny.msg.called, False)