In article <[EMAIL PROTECTED]>, Ben Finney <[EMAIL PROTECTED]> wrote:
> By definition, "private" functions are not part of the publicly > documented behaviour of the unit. Any behaviour exhibited by some > private component is seen externally as a behaviour of some public > component. You know the difference between theory and reality? In theory, there is none... Sometimes it's useful to test internal components. Imagine this class: class ArmegeddonMachine: def pushTheButton(self): "Destroy a random city" city = self._pickCity() self._destroy(city) def _pickCity(): cities = ['New York', 'Moscow', 'Tokyo', 'Beijing', 'Mumbai'] thePoorSchmucks = random.choice(cities) return 'New York' def _destroy(self, city): missle = ICBM() missle.aim(city) missle.launch() The only externally visible interface is pushTheButton(), yet you don't really want to call that during testing. What you do want to do is test that a random city really does get picked. You can do one of two things at this point. You can say, "But, that's not part of the externally visible interface" and refuse to test it, or you can figure out a way to test it. Up to you. -- http://mail.python.org/mailman/listinfo/python-list