Python Selenium nosetest utf-8 issues resolved for non standard characters

Had some trouble recently testing with some non standard characters, mainly “ and ”

I originally had this line in the Python code:

self.assertEqual(self.driver.find_element_by_xpath("html/body/example").text,"and then comes “special text” in the UI", msg=None)

When running this script, an error would be returned:

SyntaxError: Non-ASCII character '\xe2' in file 

I had to add this to the top of the Python files

# coding=UTF-8

So now the Python (Selenium) script was running fine. However, when I tried to test with nose (nosetest) I got a different error:

AssertionError: u'and then comes \u201cspecial text\u201d in the UI' != 'and then comes \xe2\x80\x9cspecial text\xe2\x80\x9d in the UI'

soooo, then I added a decode at the end of the questionable string like this:

self.assertEqual(self.driver.find_element_by_xpath("html/body/example").text,"and then comes “special text” in the UI".decode('utf-8'), msg=None)

and it magically worked.