1
0
mirror of http://aero2k.de/t/repos/urlbot-native.git synced 2017-09-06 15:25:38 +02:00

minor compability changes to code base, add simple unit test for totally critical bug

This commit is contained in:
Dino
2014-08-10 00:30:58 +02:00
parent 4994faaac8
commit 762a2618bc
2 changed files with 29 additions and 10 deletions

View File

@@ -33,7 +33,8 @@ def e(data):
def logger(severity, message):
# sev = ( 'err', 'warn', 'info' )
# if severity in sev:
sys.stderr.write(e('%s %s %s: %s' %(sys.argv[0], time.strftime('%F.%T'), severity, message)) + '\n')
args = (sys.argv[0], time.strftime('%Y-%m-%d.%H:%M:%S'), severity, message)
sys.stderr.write(e('%s %s %s: %s' % args) + '\n')
class urllib_user_agent_wrapper(urllib.FancyURLopener):
version = '''Mozilla/5.0 (X11; Linux x86_64; rv:31.0) Gecko/20100101 Firefox/31.0 Iceweasel/31.0'''
@@ -235,9 +236,10 @@ def print_version_git():
else:
print sys.argv[0] + " (unknown version)"
print_version_git()
#print_version_git()
while 1:
if __name__ == '__main__':
while 1:
try:
for f in os.listdir(event_files_dir):
if 'mcabber-' == f[:8]:

17
test_urlbot.py Normal file
View File

@@ -0,0 +1,17 @@
"""
To be executed with nose
"""
import unittest
from eventlooper import fetch_page
class TestEventlooper(unittest.TestCase):
def test_broken_url(self):
"""
Test that broken socket calls are not breaking
"""
broken_url = 'http://foo'
result = fetch_page(url=broken_url)
self.assertEqual(result, (None, None))