summaryrefslogtreecommitdiff
path: root/pylint/test/functional/bad_exception_context.py
blob: f3863438f3416f6ebb4478d9f86d2194ec37b17f (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

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