-
-
Notifications
You must be signed in to change notification settings - Fork 168
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[ADD] except-pass: Emit message If a except:pass is used (#107)
- Loading branch information
Showing
3 changed files
with
77 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
# -*- 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""" | ||
try: | ||
raise Exception('Exception') | ||
except Exception as exception: | ||
pass | ||
if exception: | ||
pass | ||
|
||
def test_4_method(self): | ||
try: | ||
raise Exception('Exception') | ||
except Exception, userError: | ||
pass | ||
if userError: | ||
pass | ||
|
||
def test_5_method(self): | ||
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): | ||
try: | ||
raise Exception('Exception') | ||
except (Exception, IndexError, NameError), exception: | ||
pass | ||
except Exception: # except-pass | ||
pass | ||
if exception: | ||
pass |