Well, I deleted this question earlier because of embarrassment, but could also share if any other newborn sees it.
I forgot to put the UnitTest line inside the __init__ method. Thus, the unit test was run every time the class was defined, and not when the object was created. The code should be:
Module1.py
Class UnitTest(): def __init__(self): print 'Mod1 UnitTest!' if __name__ == '__main__': UnitTest()
Module2.py
import Module1 Class UnitTest(): def __init__(self): print 'Mod1 UnitTest!' if __name__ == '__main__': print 'Mod2 UnitTest!'
Azhao source share