Coverage for /pythoncovmergedfiles/medio/medio/usr/local/lib/python3.8/site-packages/pexpect/exceptions.py: 53%
15 statements
« prev ^ index » next coverage.py v7.4.4, created at 2024-04-20 06:09 +0000
« prev ^ index » next coverage.py v7.4.4, created at 2024-04-20 06:09 +0000
1"""Exception classes used by Pexpect"""
3import traceback
4import sys
6class ExceptionPexpect(Exception):
7 '''Base class for all exceptions raised by this module.
8 '''
10 def __init__(self, value):
11 super(ExceptionPexpect, self).__init__(value)
12 self.value = value
14 def __str__(self):
15 return str(self.value)
17 def get_trace(self):
18 '''This returns an abbreviated stack trace with lines that only concern
19 the caller. In other words, the stack trace inside the Pexpect module
20 is not included. '''
22 tblist = traceback.extract_tb(sys.exc_info()[2])
23 tblist = [item for item in tblist if ('pexpect/__init__' not in item[0])
24 and ('pexpect/expect' not in item[0])]
25 tblist = traceback.format_list(tblist)
26 return ''.join(tblist)
29class EOF(ExceptionPexpect):
30 '''Raised when EOF is read from a child.
31 This usually means the child has exited.'''
34class TIMEOUT(ExceptionPexpect):
35 '''Raised when a read time exceeds the timeout. '''