Mocking sys.platform as 'win32' during tests.

Also merged some from jacebrowning/template-python.