Whilst writing tests I was giving considerable thought to the question of how to ensure I have tests for every class in my application.
It occurred to me that maybe I should just put the test code into the classes, thereby making it obvious that each class has a test and vice versa.
I found that this is called "self testing code" http://en.wikipedia.org/wiki/Self-testing_code
So of course in software development there's always going to be plenty of people who say THAT'S A TERRIBLE WAY TO PROGRAM, YOU CAN'T DO THAT! I'm interested in hearing what the naysayers have to say about writing self testing classes in Python. What are the reasons its a bad idea?
class MyOperation(): def some_useful_function(self): # do some useful function def some_other_function(self): # do some other function class Test_MyOperation(): def test_something(self): # some test code assert(True) def test_something_else(self): # some more test code assert(True)