diff options
Diffstat (limited to 'tests/functional/ext/broad_try_clause/broad_try_clause_extension.py')
-rw-r--r-- | tests/functional/ext/broad_try_clause/broad_try_clause_extension.py | 49 |
1 files changed, 49 insertions, 0 deletions
diff --git a/tests/functional/ext/broad_try_clause/broad_try_clause_extension.py b/tests/functional/ext/broad_try_clause/broad_try_clause_extension.py new file mode 100644 index 000000000..6fc85c6b2 --- /dev/null +++ b/tests/functional/ext/broad_try_clause/broad_try_clause_extension.py @@ -0,0 +1,49 @@ +# pylint: disable=missing-docstring, invalid-name + +MY_DICTIONARY = {"key_one": 1, "key_two": 2, "key_three": 3} + +try: # [too-many-try-statements] + value = MY_DICTIONARY["key_one"] + value += 1 + print("This one has an except clause only.") +except KeyError: + pass + +try: # [too-many-try-statements] + value = MY_DICTIONARY["key_one"] + value += 1 + print("This one has a finally clause only.") +finally: + pass + +try: # [too-many-try-statements] + value = MY_DICTIONARY["key_one"] + value += 1 + print("This one has an except clause...") + print("and also a finally clause!") +except KeyError: + pass +finally: + pass + +try: # [too-many-try-statements] + if "key_one" in MY_DICTIONARY: + entered_if_body = True + print("This verifies that content inside of an if statement is counted too.") + else: + entered_if_body = False + + while False: + print("This verifies that content inside of a while loop is counted too.") + + for item in []: + print("This verifies that content inside of a for loop is counted too.") + + +except KeyError: + pass + +try: + value = MY_DICTIONARY["key_one"] +except KeyError: + value = 0 |