9 ms·
OK, 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
by kstrauser 12y ago
OK, 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.