3 ms·
Why would you need to do this for a unit test? Can't you just test the properties of the return value of the outer function like you would for any other value?
by sinkasapa 12y ago
Why would you need to do this for a unit test? Can't you just test the properties of the return value of the outer function like you would for any other value? If the function returned an object, how would that be different?
- kstrauser 12y agoOK, I think some wires got crossed. You can trivially create a unit test for the outer function that indirectly tests the output of the inner function. What the GGP meant was that you can't directly test the inner function because you can't access it and so can't call inner() from the unit test. For example, given: def add(a, b): def inner(): return a + b return inner() You can write tests like: assert add(1, 2) == 3 But you can't write something like: assert add.inner() == 3 If inner() were doing something nontrivial, you'd probably want it to be standalone.