Doppel

Testing library
Download

Doppel Ranking & Summary

Advertisement

  • Rating:
  • License:
  • MIT/X Consortium Lic...
  • Price:
  • FREE
  • Publisher Name:
  • Darius Powell

Doppel Tags


Doppel Description

Testing library Doppel is a Python module that allows writing tests as a simple sequence of ordered steps.Each step is a call in or a call out. Where a call in is the test code calling into the code under test and a call out is the source code calling out onto a fn replaced by a doppel.Call InThe following examples assume that the test expectations object t has been created:with doppel.TestExpectations() as t:To call into the code under test:t.call(examples.fn1)To call into the code under test with args:t.call(examples.fn2).args('arg1', 'arg2', arg3='arg3', arg4='arg4')To not verify the return value:t.call(examples.fn1)To verify the return value as a literal:t.call(examples.fn1).returns('fn1 called')To verify the return value using a function:def verify_fn(result): return result == 'fn1 called't.call(examples.get_string).returns(verify_fn)Call OutThe following examples assume that fn_replaced has been replaced:class TestExamples(doppel.TestCaseReplacing('examples.fn_replaced')):Further, they assume that the test expectations object t has been created and that the code under test has been called:with doppel.TestExpectations() as t: t.call(examples.fn3).args('arg1', 'arg2', arg3='arg3', arg4='arg4')To expect a call out with args not verified:examples.fn_replaced()To expect a call out with args verified as a literal:examples.fn_replaced('arg1', 'arg2', arg3='arg3', arg4='arg4')To expect a call out with args verified using a function:def verify_fn(*args, **kwargs): return args == ('arg1', 'arg2') and kwargs == {'arg3': 'arg3', 'arg4': 'arg4'}examples.fn_replaced(verify_fn)To return a doppel:examples.fn_replaced()To return a literal:examples.fn_replaced().returns('ret1')To return a value supplied by a function:def returns_fn(): return 'ret1'examples.fn_replaced().returns(returns_fn)To raise an exception:examples.fn_replaced().raises(Exception('exception1')) Requirements: · Python


Doppel Related Software