Skip to content

Commit

Permalink
appease flake8
Browse files Browse the repository at this point in the history
  • Loading branch information
yrro committed Mar 12, 2024
1 parent c55e556 commit e82e074
Showing 1 changed file with 23 additions and 9 deletions.
32 changes: 23 additions & 9 deletions tests/test_plugins.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ class plugin_slow_catching_exception_and_ignoring(Plugin):
def check(self):
try:
time.sleep(5)
except:
except Exception:
pass
return # ugly syntax to let us yield no results
yield
Expand All @@ -46,7 +46,11 @@ def check(self):
try:
time.sleep(5)
except Exception as e:
yield Result(self, constants.ERROR, key='test', msg='fail', exception=str(e))
yield Result(
self, constants.ERROR,
key='test', msg='fail',
exception=str(e)
)

class plugin_slow_raising_exception(Plugin):
'''
Expand All @@ -58,7 +62,7 @@ class plugin_slow_raising_exception(Plugin):
def check(self):
try:
time.sleep(5)
except:
except Exception:
raise Exception("I didn't expect an exception to be thrown")

class plugin_fast(Plugin):
Expand All @@ -80,28 +84,38 @@ def check(self):

assert 7 == len(results.results)

assert results.results[0].kw.get('exception') == 'Health check test_plugins:plugin_slow_passing_exception_up cancelled after 1 sec'
assert results.results[0].kw.get('exception') == 'Health check' \
' test_plugins:plugin_slow_passing_exception_up' \
' cancelled after 1 sec'
assert results.results[0].result == constants.ERROR
assert not results.results[0].kw.get('traceback')

assert results.results[1].kw.get('exception') == 'Health check test_plugins:plugin_slow_catching_exception_and_ignoring cancelled after 1 sec'
assert results.results[1].kw.get('exception') == 'Health check' \
' test_plugins:plugin_slow_catching_exception_and_ignoring' \
' cancelled after 1 sec'
assert results.results[1].result == constants.ERROR
assert not results.results[1].kw.get('traceback')

assert results.results[2].kw.get('exception') == 'Health check test_plugins:plugin_slow_catching_exception_and_handling cancelled after 1 sec'
assert results.results[2].kw.get('exception') == 'Health check' \
' test_plugins:plugin_slow_catching_exception_and_handling' \
' cancelled after 1 sec'
assert results.results[2].result == constants.ERROR
assert results.results[2].kw.get('msg') == 'fail'
assert not results.results[2].kw.get('traceback')

assert results.results[3].kw.get('exception')== 'Health check test_plugins:plugin_slow_catching_exception_and_handling cancelled after 1 sec'
assert results.results[3].kw.get('exception') == 'Health check' \
' test_plugins:plugin_slow_catching_exception_and_handling' \
' cancelled after 1 sec'
assert results.results[3].result == constants.ERROR
assert not results.results[3].kw.get('traceback')

assert results.results[4].kw.get('exception') == "I didn't expect an exception to be thrown"
assert results.results[4].kw.get('exception') == "I didn't expect an" \
" exception to be thrown"
assert results.results[4].result == constants.CRITICAL
assert results.results[4].kw.get('traceback')

assert results.results[5].kw.get('exception') == 'Health check test_plugins:plugin_slow_raising_exception cancelled after 1 sec'
assert results.results[5].kw.get('exception') == 'Health check' \
' test_plugins:plugin_slow_raising_exception cancelled after 1 sec'
assert results.results[5].result == constants.ERROR
assert not results.results[5].kw.get('traceback')

Expand Down

0 comments on commit e82e074

Please sign in to comment.