""" Doctest query. When I use doctest on this file, only one of the pieces of documentation is tested. Why? (Here is the output from CcCc in emacs.) Trying: print "Documentation at the beginning of a class gets tested" Expecting: Documentation at the beginning of a class gets tested ok ... 1 passed and 0 failed. Test passed. """ class DoesGetTested: """ >>> print "Documentation at the beginning of a class gets tested" Documentation at the beginning of a class gets tested """ def __init__(self,rule): self.rule=rule print "hello" pass class DoesNotGetTested: def __init__(self,rule): self.rule=rule print "hello" pass """ What if I prefer to put my documentation at the end of a class? >>> a = "Not tested!" >>> print a Not tested! """ class DoesNotGetTested: def __init__(self,rule): self.rule=rule print "hello" pass """ Middle of a class, same result. >>> a = "Not tested!" >>> print a Not tested! """ def methodA(self): print "Hi" pass def blah1(): pass """ Floating documentation in the middle of a bunch of functions is not tested either. >>> blah2() Blah2 output """ def blah2(): print "Blah2 output" pass if __name__ == '__main__': import doctest doctest.testmod(None,None,None,True) pass