Every module has a __name__. If that string variable is "main" it means the module is running standalone. This enables the original test code to run only when the module runs standalone; otherwise the test code will be prevented from running when the module is used to import classes. So you get both. It's a useful and standard technique.
Every module has a
__name__
. If that string variable is "main" it means the module is running standalone. This enables the original test code to run only when the module runs standalone; otherwise the test code will be prevented from running when the module is used to import classes. So you get both. It's a useful and standard technique.