-
-
Notifications
You must be signed in to change notification settings - Fork 170
/
Copy pathexcept_pass.py
65 lines (56 loc) · 1.59 KB
/
except_pass.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
# -*- coding: utf-8 -*-
"""Test Except Pass usage"""
class TestExceptPass(object):
"""Test Except Pass class """
def test_method(self):
try:
raise Exception('Exception')
except Exception: # except-pass
pass
def test_2_method(self):
"""This pass is skip for body of except has more than one line """
try:
raise Exception('Exception')
except Exception:
pass
print('Exception')
def test_3_method(self):
"""This pass is skip for the exception is assigned"""
exception = False
try:
raise Exception('Exception')
except Exception as exception:
pass
if exception:
pass
def test_4_method(self):
userError = False
try:
raise Exception('Exception')
except Exception as userError:
pass
if userError:
pass
def test_5_method(self):
exception = False
try:
raise Exception('Exception')
except (Exception, IndexError) as exception:
pass
if exception:
pass
def test_6_method(self):
try:
raise Exception('Exception')
except (Exception, IndexError): # except-pass
pass
def test_7_method(self):
exception = False
try:
raise Exception('Exception')
except (Exception, IndexError, NameError) as exception:
pass
except Exception: # except-pass
pass
if exception:
pass