Statistics
| Revision:

gvsig-scripting / org.gvsig.scripting / trunk / org.gvsig.scripting / org.gvsig.scripting.app / org.gvsig.scripting.app.mainplugin / src / main / resources-plugin / scripting / lib / pylint / test / functional / invalid_exceptions_raised.py @ 745

History | View | Annotate | Download (1.8 KB)

1
# pylint:disable=too-few-public-methods,old-style-class,no-init,import-error,missing-docstring, not-callable
2
"""test pb with exceptions and old/new style classes"""
3

    
4

    
5
class ValidException(Exception):
6
    """Valid Exception."""
7

    
8
class OldStyleClass:
9
    """Not an exception."""
10

    
11
class NewStyleClass(object):
12
    """Not an exception."""
13

    
14

    
15
def good_case():
16
    """raise"""
17
    raise ValidException('hop')
18

    
19
def good_case1():
20
    """zlib.error is defined in C module."""
21
    import zlib
22
    raise zlib.error(4)
23

    
24
def good_case2():
25
    """decimal.DivisionByZero is defined in C on Python 3."""
26
    import decimal
27
    raise decimal.DivisionByZero(4)
28

    
29
def good_case3():
30
    """io.BlockingIOError is defined in C."""
31
    import io
32
    raise io.BlockingIOError
33

    
34
def bad_case0():
35
    """raise"""
36
    # +2:<3.0:[nonstandard-exception]
37
    # +1:>=3.0:[raising-non-exception]
38
    raise OldStyleClass('hop')
39

    
40
def bad_case1():
41
    """raise"""
42
    raise NewStyleClass()  # [raising-non-exception]
43

    
44
def bad_case2():
45
    """raise"""
46
    # +2:<3.0:[nonstandard-exception]
47
    # +1:>=3.0:[raising-non-exception]
48
    raise OldStyleClass('hop')
49

    
50
def bad_case3():
51
    """raise"""
52
    raise NewStyleClass  # [raising-non-exception]
53

    
54
def bad_case4():
55
    """raise"""
56
    raise NotImplemented('hop')  # [notimplemented-raised]
57

    
58
def bad_case5():
59
    """raise"""
60
    raise 1  # [raising-bad-type]
61

    
62
def bad_case6():
63
    """raise"""
64
    raise None  # [raising-bad-type]
65

    
66
def bad_case7():
67
    """raise list"""
68
    raise list # [raising-non-exception]
69

    
70
def bad_case8():
71
    """raise tuple"""
72
    raise tuple # [raising-non-exception]
73

    
74
def bad_case9():
75
    """raise dict"""
76
    raise dict # [raising-non-exception]
77

    
78
def unknown_bases():
79
    """Don't emit when we don't know the bases."""
80
    from lala import bala
81
    class MyException(bala):
82
        pass
83
    raise MyException