Why does python not have a mechanism for data hiding?

Ben Finney bignose+hates-spam at benfinney.id.au
Thu Jun 5 01:47:11 CEST 2008

Ethan Furman <ethan at stoneleaf.us> writes:

> I must be missing something in this discussion. Perhaps it's the
> appropriate point of view. At any rate, it seems to me that any and
> every function should be tested to ensure proper results.

I restrict that to "every proper behaviour the system is expected to
provide should be tested".

The corollary is that every behaviour is either:

  * part of an expected external behaviour, and thus unit tests need
    to assert that behaviour through the unit's public interface

  * not part of an expected external behaviour, and thus needs to be
    removed from the system

This also forces a decision about "private" functionality: Either it's
part of some public functionality, and thus needs to be tested via
that public functionality; or it's not part of any public
functionality, and needs to be removed.

> It's my understanding that unit testing (a.k.a. PyUnit) is designed
> for just such a purpose.


 \     "I was in the first submarine. Instead of a periscope, they had |
  `\            a kaleidoscope. 'We're surrounded.'"  -- Steven Wright |
_o__)                                                                  |
Ben Finney

More information about the Python-list mailing list