1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16 from elisa.core.tests.elisa_test_case import ElisaTestCase
17 from elisa.core.utils import exception_hook
18 import sys, os, tempfile, platform
19
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
30
32 sys.excepthook = self._old_hook
33
35 sys.excepthook = exception_hook.ExceptionHook(format='text', logdir='/tmp',
36 file=sys.stderr, display=False)
37 try:
38 raise Exception()
39 except:
40 sys.excepthook.handle()
41
43 errors = os.tmpfile()
44 sys.excepthook = exception_hook.ExceptionHook(format='text', logdir='/tmp',
45 file=errors, display=True)
46 try:
47 raise Exception()
48 except:
49 sys.excepthook.handle()
50 errors.seek(0)
51 data = errors.read()
52 self.failUnless(data)
53
54 errors.close()
55
57 errors = os.tmpfile()
58 sys.excepthook = exception_hook.ExceptionHook(format='html', logdir='/tmp',
59 file=errors, display=True)
60 try:
61 raise Exception()
62 except:
63 sys.excepthook.handle()
64 errors.seek(0)
65 data = errors.read()
66 self.failUnless(data)
67
68 errors.close()
69