diff options
author | Julien Cristau <julien.cristau@logilab.fr> | 2014-11-28 14:47:13 +0100 |
---|---|---|
committer | Julien Cristau <julien.cristau@logilab.fr> | 2014-11-28 14:47:13 +0100 |
commit | d06bab438fd83ca1cd2326aeeba4729144765a2b (patch) | |
tree | 621346f26362db20c89242802f65ac65704d0859 /test/utils.py | |
parent | e8a83ac75b91fd8bf770caff17b9fe96635abd08 (diff) | |
download | logilab-common-d06bab438fd83ca1cd2326aeeba4729144765a2b.tar.gz |
[ureports] write unicode not bytes (closes #277372)
Diffstat (limited to 'test/utils.py')
-rw-r--r-- | test/utils.py | 37 |
1 files changed, 23 insertions, 14 deletions
diff --git a/test/utils.py b/test/utils.py index da315e4..ca1730e 100644 --- a/test/utils.py +++ b/test/utils.py @@ -20,24 +20,33 @@ from __future__ import print_function -from logilab.common.compat import StringIO +import sys +from io import StringIO +buffers = [StringIO] +if sys.version_info < (3, 0): + from cStringIO import StringIO as cStringIO + from StringIO import StringIO as pStringIO + buffers += [cStringIO, pStringIO] + from logilab.common.ureports.nodes import * class WriterTC: def _test_output(self, test_id, layout, msg=None): - buffer = StringIO() - self.writer.format(layout, buffer) - got = buffer.getvalue() - expected = getattr(self, test_id) - try: - self.assertMultiLineEqual(got, expected) - except: - print('**** got for %s' % test_id) - print(got) - print('**** while expected') - print(expected) - print('****') - raise + for buffercls in buffers: + buffer = buffercls() + self.writer.format(layout, buffer) + got = buffer.getvalue() + expected = getattr(self, test_id) + try: + self.assertMultiLineEqual(got, expected) + except: + print('**** using a %s' % buffer.__class__) + print('**** got for %s' % test_id) + print(got) + print('**** while expected') + print(expected) + print('****') + raise def test_section(self): layout = Section('Section title', |