Q:

Doing functional tests on login process

I am doing some tests using selenium on a website. One of the main things that needs to be tested is the sign up/log in process. There are a lot of variables here, and several different network settings that need to be confirmed on setup.
The sign-up process sends a confirmation email link to complete registration. 
How would this be tested using Selenium. It seems like I'd need to do the sign-up on the site, then log into my gmail account, and then click the registration link -- is there a better way to do this?

A:

This is what I ended up doing. The only problem is that there's really no way to tell when the email will arrive, and it can take quite some time...
def _get_last_message(self):
    mail = imaplib.IMAP4_SSL('imap.gmail.com')
    mail.login(MAIL_USERNAME, MAIL_PASSWORD)
    mail.select("inbox")
    result, data = mail.search(None, "ALL")
    latest_email_id = data[0].split()[-1]
    result, data = mail.fetch(latest_email_id, "(RFC822)")
    raw_email = data[0][1]
    return raw_email

