[python-nl] testing
C.T. Matsumoto
c.t.matsumoto at gmail.com
Fri Apr 23 11:56:43 CEST 2010
Hello all,
Does anyone know a good way to test function objects? It's easy enough
to test class attributes, but for some reason I'm finding it difficult
to test if a function has the right 'attributes'.
I'm using unittest and nosetests.
Sample function:
def foo():
x = 3
y = 4
This example is super simple but lets pretend that x and y were derived
from some more complicated code that was done inside the function. The
best way I can come up with is moving the complicated code into another
function that returns the derived value and then test the return value,
but if i want to keep the code in the function how can I get to those
'attribute' values to test?
Thanks,
T
--
C.T. Matsumoto
Claes de Vrieselaan 60a III
3021 JR Rotterdam
The Netherlands
tel.: +31 (0)6 41 45 08 54
More information about the Python-nl
mailing list