unittest and private methods

Yin yin_12180 at yahoo.com
Tue Feb 3 06:58:13 CET 2004


I am an avid user of unittest and write tests for everything. Every so
often, I write a class that has some private methods that I only want
to be called from within the class. I usually write unittests for
these private methods using the mangled form of the call from a test
script file. It's not very elegant, and I wanted to get some feedback
on how others write unit tests for private methods.

I suppose that I could just not use private methods, and have them all
be public, but it's a lot cleaner for me to hide all the other
extraneous methods rather than expose them to the public.

Thanks,
Yin



More information about the Python-list mailing list