<s> import os <EOL> import sys <EOL> import maya . utils <EOL> import traceback <EOL> import unittest <EOL> import re <EOL> import pymel . versions <EOL> import shutil <EOL> import string <EOL> thisFile = os . path . basename ( __file__ ) <EOL> fileReStr = r'<STR_LIT>' <EOL> fileLineRe1 = re . compile ( r'<STR_LIT>' % fileReStr ) <EOL> fileLineRe2 = re . compile ( r'<STR_LIT>' % fileReStr ) <EOL> def replacePath ( match ) : <EOL> groups = match . groupdict ( ) <EOL> file = groups . get ( '<STR_LIT:file>' , '<STR_LIT>' ) <EOL> if file : <EOL> dir = groups . get ( '<STR_LIT>' , '<STR_LIT>' ) <EOL> if dir : <EOL> dir = '<STR_LIT>' <EOL> path = '<STR_LIT>' % ( dir , file ) <EOL> else : <EOL> path = groups [ '<STR_LIT>' ] <EOL> return path <EOL> def fileLineReplacer1 ( match ) : <EOL> return '<STR_LIT>' % replacePath ( match ) <EOL> def fileLineReplacer2 ( match ) : <EOL> return '<STR_LIT>' % replacePath ( match ) <EOL> errorCodes = [ <EOL> ( '<STR_LIT>' , <EOL> ( <EOL> """<STR_LIT>""" , <EOL> """<STR_LIT>""" , <EOL> """<STR_LIT>""" <EOL> ) ) , <EOL> ( '<STR_LIT>' , <EOL> ( <EOL> """<STR_LIT>""" , <EOL> """<STR_LIT>""" , <EOL> """<STR_LIT>""" <EOL> ) ) , <EOL> ( "<STR_LIT>" , <EOL> ( <EOL> """<STR_LIT>""" , <EOL> """<STR_LIT>""" , <EOL> """<STR_LIT>""" <EOL> ) ) , <EOL> ] <EOL> class TestMayaIntegration ( unittest . TestCase ) : <EOL> if pymel . versions . current ( ) >= pymel . versions . v2011 : <EOL> import pymel . core <EOL> def test_guiExceptionFormatting ( self ) : <EOL> for codeStr , messages in errorCodes : <EOL> try : <EOL> eval ( codeStr ) <EOL> except Exception , e : <EOL> type , value , traceback = sys . exc_info ( ) <EOL> for level in range ( <NUM_LIT:3> ) : <EOL> res = maya . utils . formatGuiException ( type , value , traceback , level ) <EOL> rawres = res <EOL> res = fileLineRe1 . sub ( fileLineReplacer1 , res ) <EOL> res = fileLineRe2 . sub ( fileLineReplacer2 , res ) <EOL> res = res . replace ( '<STR_LIT>' , '<STR_LIT>' ) <EOL> res = res . replace ( '<STR_LIT>' , '<STR_LIT>' ) <EOL> res = res . replace ( '<STR_LIT>' , '<STR_LIT>' ) <EOL> expected = messages [ level ] <EOL> if res != expected : <EOL> print '<STR_LIT>' % level <EOL> print '<STR_LIT:*>' * <NUM_LIT> <EOL> print "<STR_LIT>" <EOL> print rawres <EOL> print '<STR_LIT:*>' * <NUM_LIT> <EOL> print '<STR_LIT:*>' * <NUM_LIT> <EOL> print "<STR_LIT>" <EOL> print res <EOL> print '<STR_LIT:*>' * <NUM_LIT> <EOL> print '<STR_LIT:*>' * <NUM_LIT> <EOL> print "<STR_LIT>" <EOL> print expected <EOL> print '<STR_LIT:*>' * <NUM_LIT> <EOL> self . assertEqual ( res , expected ) <EOL> finally : <EOL> del traceback </s>
