doppel 0.7
Testing lib - under development
Doppel 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 In
The 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 Out
The 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'))
| File | Type | Py Version | Uploaded on | Size | # downloads |
|---|---|---|---|---|---|
| doppel-0.7.tar.gz (md5) | Source | 2009-11-08 09:58:30.616920 | 28KB | 28 | |
| doppel-0.7-py2.6.egg (md5) | Python Egg | 2.6 | 2009-11-08 09:58:32.330943 | 10KB | 37 |
- Author: Darius Powell <dariusp686 at gmail com>
- Home Page: http://pypi.python.org/pypi/doppel
- License: MIT License
- Categories
- Package Index Owner: dariusp
- DOAP record: doppel-0.7.xml
Log in to rate this package.
