2 ms·
Inner functions in closures are tested in much the same way as methods are tested for classes. closure = OuterFunc(var1, var2) self.assertEqual(closure(v
by raymondh 12y ago
Inner functions in closures are tested in much the same way as methods are tested for classes.
closure = OuterFunc(var1, var2)
self.assertEqual(closure(var3), result)
inst = SomeClass(var1, var2)
self.assertEqual(inst.somemethod(var3), result)
When you think about it, there isn't much sense to calling an inner function without having called the enclosing function (the inner function typically depends on data trapped or closed by the outer function).
Likewise, there isn't much sense in calling a method without having instantiated a class (methods typically depend on data stored in the instance).