Q:

Python Unit Test

I'm new into unit testing. I was wondering how would you unit test the code below using python unit test. You can use any kind of framework for testing but please do mention why and be detail. Really do appreciate everyone's help.  
BTW you can make changes to the code as long as it does what its doing right now. It was BS anyway :P
pyg = 'ay'

original = raw_input('Enter a word:')

word = original.lower()

first = word[0]

    if first == "a" and "e" and "i" and "o" and "u":
        new_word = word + pyg
        print new_word
    else:
        consonant_fix = word[1:]
        new_word = consonant_fix + word[0] + pyg
        print new_word

A:

I don't think that this is a good candidate for unit testing.
The I/O should not matter.
Better to refactor this into a function that takes in a string, operates on it, and returns a new string.  Then you can write unit tests with specific inputs to check the behavior you want.
As written, your code isn't testable.
Here's how I'd rewrite it:
def rearrange(original, pyg):
    word = original.lower()
    first = word[0]
    if first == "a" and "e" and "i" and "o" and "u":
        new_word = word + pyg
    else:
        consonant_fix = word[1:]
        new_word = consonant_fix + word[0] + pyg
    return new_word

if __name__ == '__main__':
    pyg = 'ay'
    original = raw_input('Enter a word:')
    print rearrange(original, pyg)

You can test this rearrange() function with different inputs now.

