def behavior(its): from specfor import mock empty_mock = mock.define("empty") empty = empty_mock("id-0") mock.check(empty) pass
def behavior(its): from specfor import mock callbacks_mock = mock.define("callbacks") method_def = callbacks_mock.method("init") @method_def.define(ordered=1) def init(self): pass # next of ordered count should increment just 1 method_def = callbacks_mock.method("prepare") @method_def.define(ordered=2) def prepare(self): pass method_def = callbacks_mock.method("call") @method_def.define(ordered=3) def call(self): pass method_def = callbacks_mock.method("cleanup") @method_def.define(ordered=4) def cleanup(self): pass method_def = callbacks_mock.method("destroy") @method_def.define(ordered=5) def destroy(self): pass callbacks = callbacks_mock("id-0") # raise AssertionError if all ordered methods are not called with the.raising[AssertionError]: mock.check(callbacks) callbacks.init() callbacks.prepare() callbacks.call() # raise AssertionError if method called invalid order with the.raising[AssertionError]: callbacks.destroy() callbacks.cleanup() callbacks.destroy() mock.check(callbacks) pass
def behavior(its): from specfor import mock counter_mock = mock.define("counter") method_def = counter_mock.method("count") @method_def.define(between=(1, 3)) def count(self): return 1 counter = counter_mock("id-0") with the.raising[AssertionError]: mock.check(counter) counter.count() mock.check(counter) counter.count() mock.check(counter) counter.count() mock.check(counter) counter.count() with the.raising[AssertionError]: mock.check(counter) pass