diff options
author | Victor Stinner <victor.stinner@enovance.com> | 2014-03-31 12:42:50 +0200 |
---|---|---|
committer | Chmouel Boudjnah <chmouel@enovance.com> | 2014-04-15 11:38:26 -0400 |
commit | ea498fb052e6101e0b986fb8e4927a9fda77b04f (patch) | |
tree | dfe9fc83a78b97f6ec3362e96dab1a0587077195 /tests/test_multithreading.py | |
parent | 155053ea61bb7a9afc19dc289886231e238bb298 (diff) | |
download | python-swiftclient-ea498fb052e6101e0b986fb8e4927a9fda77b04f.tar.gz |
Fix test_multithreading on Python 3
* On Python 3, the printer doesn't encode Unicode to utf8 anymore, since
print() expects a Unicode string.
* Update unit tests for Python 3 since repr() doesn't escape non-ASCII
characters in Unicode strings anymore:
http://legacy.python.org/dev/peps/pep-3138/
Change-Id: I89471019d691a46651312d6a49964b719192148a
Diffstat (limited to 'tests/test_multithreading.py')
-rw-r--r-- | tests/test_multithreading.py | 12 |
1 files changed, 9 insertions, 3 deletions
diff --git a/tests/test_multithreading.py b/tests/test_multithreading.py index 81b0766..875e43a 100644 --- a/tests/test_multithreading.py +++ b/tests/test_multithreading.py @@ -320,16 +320,22 @@ class TestMultiThreadingManager(ThreadTestCase): self.assertEqual(self.starting_thread_count, threading.active_count()) out_stream.seek(0) + if six.PY3: + over_the = "over the '\u062a\u062a'\n" + else: + over_the = "over the u'\\u062a\\u062a'\n" self.assertEqual([ 'one-argument\n', 'one fish, 88 fish\n', - 'some\n', 'where\n', "over the u'\\u062a\\u062a'\n", + 'some\n', 'where\n', over_the, ], list(out_stream.readlines())) err_stream.seek(0) + first_item = u'I have 99 problems, but a \u062A\u062A is not one\n' + if six.PY2: + first_item = first_item.encode('utf8') self.assertEqual([ - u'I have 99 problems, but a \u062A\u062A is not one\n'.encode( - 'utf8'), + first_item, 'one-error-argument\n', 'Sometimes\n', '3.1% just\n', 'does not\n', 'work!\n', ], list(err_stream.readlines())) |