14 """Code for instructing systems under test to block or fail."""
24 """Simulates a programming defect raised into in a system under test.
26 Use of a standard exception type is too easily misconstrued as an actual
27 defect in either the test infrastructure or the system under test.
31 class Control(six.with_metaclass(abc.ABCMeta)):
32 """An object that accepts program control from a system under test.
34 Systems under test passed a Control should call its control() method
35 frequently during execution. The control() method may block, raise an
36 exception, or do nothing, all according to the enclosing test's desire for
37 the system under test to simulate freezing, failing, or functioning.
42 """Potentially does anything."""
43 raise NotImplementedError()
47 """A Control that can be used to pause or fail code under control.
49 This object is only safe for use from two threads: one of the system under
50 test calling control and the other from the test system calling pause,
51 block_until_paused, and fail.
71 @contextlib.contextmanager
73 """Pauses code under control while controlling code is in context."""
82 """Blocks controlling code until code under control is paused.
84 May only be called within the context of a pause call.
90 @contextlib.contextmanager
92 """Fails code under control while controlling code is in context."""