From 8fa37b30567b018f8f32df4f61be39d88da7b713 Mon Sep 17 00:00:00 2001 From: mutantmonkey Date: Thu, 28 Nov 2013 23:28:11 -0800 Subject: [PATCH] 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. --- modules/head.py | 2 +- modules/test/test_head.py | 9 +++++++++ 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/modules/head.py b/modules/head.py index 3835522..bc0df6f 100644 --- a/modules/head.py +++ b/modules/head.py @@ -152,7 +152,7 @@ def gettitle(phenny, uri): #bytes = u.read(262144) #u.close() - except web.ConnectionError: + except: return m = r_title.search(bytes) diff --git a/modules/test/test_head.py b/modules/test/test_head.py index d92ceee..95ed2c0 100644 --- a/modules/test/test_head.py +++ b/modules/test/test_head.py @@ -49,3 +49,12 @@ class TestHead(unittest.TestCase): snarfuri(self.phenny, input) 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)