You can only read and write bytes from cStringIO.StringIO, so the problem with this assertion is it's comparing bytes with unicode:
fp.seek(0) self.assertThat(fp.read(), Contains(u'some unicode char (\xe1)'))
I'd write it instead asserting the UTF-8 byte string:
self.assertThat(fp.getvalue() Contains("some unicode char (\xc3\xa1)"))
Or with `.decode("utf-8")` after the getvalue if you want to keep the unicode Contains which is neater, especially with older testtools versions.
You can only read and write bytes from cStringIO.StringIO, so the problem with this assertion is it's comparing bytes with unicode:
fp.seek(0) assertThat( fp.read( ), Contains(u'some unicode char (\xe1)'))
self.
I'd write it instead asserting the UTF-8 byte string:
self. assertThat( fp.getvalue( ) Contains("some unicode char (\xc3\xa1)"))
Or with `.decode("utf-8")` after the getvalue if you want to keep the unicode Contains which is neater, especially with older testtools versions.