When you write some scripts that are self sufficient, is it a bad idea to use the if __name__ == '__main__' as a place to write tests?
Best practice is to put the tests in separate units that use the unittest module. This separation allows you to keep the main code clean (no need for lots of testing helper functions) and encourages you to write good comprehensive tests since you are not inhibited by cluttering the main code.
Use if __name__ == '__main__': for tests