Package elisa :: Package core :: Package tests :: Module test_utils_exception_hook

Source Code for Module elisa.core.tests.test_utils_exception_hook

 1  # Moovida - Home multimedia server 
 2  # Copyright (C) 2006-2009 Fluendo Embedded S.L. (www.fluendo.com). 
 3  # All rights reserved. 
 4  # 
 5  # This file is available under one of two license agreements. 
 6  # 
 7  # This file is licensed under the GPL version 3. 
 8  # See "LICENSE.GPL" in the root of this distribution including a special 
 9  # exception to use Moovida with Fluendo's plugins. 
10  # 
11  # The GPL part of Moovida is also available under a commercial licensing 
12  # agreement from Fluendo. 
13  # See "LICENSE.Moovida" in the root directory of this distribution package 
14  # for details on that license. 
15   
16  from elisa.core.tests.elisa_test_case import ElisaTestCase 
17  from elisa.core.utils import exception_hook 
18  import sys, platform 
19   
20 -class TestExceptionHook(ElisaTestCase):
21
22 - def __init__(self, methodName='runTest'):
23 ElisaTestCase.__init__(self, methodName) 24 if platform.system() == 'Windows': 25 self.skip = "test not supported under windows"
26
27 - def test_failure_formatting(self):
28 # test, that it does not fail 29 from twisted.python.failure import Failure 30 f = Failure(Exception) 31 data = exception_hook.format_failure(f)
32
34 # test, that it does not fail 35 try: 36 raise Exception 37 except: 38 info = sys.exc_info() 39 data = exception_hook.format_traceback() 40 data2 = exception_hook.format_traceback(*info)
41
42 - def test_data_writing(self):
43 data = 'Pocahontas\nMikey Mouse' 44 path = exception_hook.write_to_logfile(data) 45 self.failUnless(path) 46 47 r = open(path,'r').read() 48 self.assertEquals(data, r)
49
50 - def test_wrong_logdirs(self):
51 path = exception_hook.write_to_logfile('', logdir='/') 52 self.failIf(path) 53 54 path = exception_hook.write_to_logfile('', logdir='/never') 55 self.failIf(path) 56 57 path = exception_hook.write_to_logfile('', logdir='/var/log') 58 self.failIf(path)
59