Skip to content

Instantly share code, notes, and snippets.

@Peaker
Created October 30, 2019 07:50
Show Gist options
  • Save Peaker/958c760e28a1994ba9c931b2383c901e to your computer and use it in GitHub Desktop.
Save Peaker/958c760e28a1994ba9c931b2383c901e to your computer and use it in GitHub Desktop.
from contextlib import contextmanager
@contextmanager
def injected_fault(params):
fault_manager.inject(params)
try:
yield
finally:
fault_manager.clear(params)
def some_test():
with injected_fault("disk_failure", offset):
expect_exception(EIO, read file ...)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment