mirror of
https://github.com/ansible/awx.git
synced 2026-03-17 17:07:33 -02:30
Use built-in suppress from contextlib
In python3, we can use the built-in suppress from contextlib https://docs.python.org/3/library/contextlib.html#contextlib.suppress
This commit is contained in:
@@ -216,32 +216,6 @@ class RecordingCallback(object):
|
||||
return self.value
|
||||
|
||||
|
||||
def test_suppress():
|
||||
callback = RecordingCallback()
|
||||
|
||||
with utils.suppress(ZeroDivisionError, IndexError):
|
||||
raise ZeroDivisionError
|
||||
callback()
|
||||
raise IndexError
|
||||
raise KeyError
|
||||
assert callback.call_count == 0
|
||||
|
||||
with utils.suppress(ZeroDivisionError, IndexError):
|
||||
raise IndexError
|
||||
callback()
|
||||
raise ZeroDivisionError
|
||||
raise KeyError
|
||||
assert callback.call_count == 0
|
||||
|
||||
with pytest.raises(KeyError):
|
||||
with utils.suppress(ZeroDivisionError, IndexError):
|
||||
raise KeyError
|
||||
callback()
|
||||
raise ZeroDivisionError
|
||||
raise IndexError
|
||||
assert callback.call_count == 0
|
||||
|
||||
|
||||
class TestPollUntil(object):
|
||||
@pytest.mark.parametrize('timeout', [0, 0.0, -0.5, -1, -9999999])
|
||||
def test_callback_called_once_for_non_positive_timeout(self, timeout):
|
||||
|
||||
Reference in New Issue
Block a user