Say I have a module with the following:
def main():
pass
if __name__ == \"__main__\":
main()
I want to write a unit test for the b
I found this solution helpful. Works well if you use a function to keep all your script code. The code will be handled as one code line. It doesn't matter if the entire line was executed for coverage counter (though this is not what you would actually actually expect by 100% coverage) The trick is also accepted pylint. ;-)
if __name__ == '__main__': \
main()