Собвсно сабж. Как исправить?
In [27]: re.sub("test"+"(?i)",'111','test')
Out[27]: u'111'
In [28]: re.sub("test"+"(?i)",'111','tEsT')
Out[28]: u'111'
In [29]: re.sub("тест"+"(?i)",'111','тест')
Out[29]: u'111'
In [30]: re.sub("тест"+"(?i)",'111','тесТ')
Out[30]: u'\xd1\x82\xd0\xb5\xd1\x81\xd0\xa2'