summaryrefslogtreecommitdiff
path: root/pylint/test/functional/bad_exception_context.py
blob: af3e4fb9f8e7115558cc095a9e760ed6bbcae742 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
"""Check that raise ... from .. uses a proper exception context """

# pylint: disable=unreachable, import-error, multiple-imports

import socket, unknown

__revision__ = 0

class ExceptionSubclass(Exception):
    """ subclass """

def test():
    """ docstring """
    raise IndexError from 1 # [bad-exception-context]
    raise IndexError from None
    raise IndexError from ZeroDivisionError
    raise IndexError from object() # [bad-exception-context]
    raise IndexError from ExceptionSubclass
    raise IndexError from socket.error
    raise IndexError() from None
    raise IndexError() from ZeroDivisionError
    raise IndexError() from ZeroDivisionError()
    raise IndexError() from object() # [bad-exception-context]
    raise IndexError() from unknown