Port test_exception to Python 3

* FakeNovaException_Remote: on Python 3, define a __str__() method
  instead of __unicode__() method. str(exc) now calls __str__() now
  Pyton 3, __unicode__() is no more used.
* tox.ini: add nova.tests.unit.test_exception to Python 3.

Blueprint nova-python3
Change-Id: Ia3e3f253aa57b75a47f3ba044d2c539f9ce48aea
This commit is contained in:
Victor Stinner 2015-07-03 11:16:01 +02:00
parent 49873d8f6d
commit ee4a2a4bb7
2 changed files with 7 additions and 2 deletions

View File

@ -123,8 +123,12 @@ class NovaExceptionTestCase(test.NoDBTestCase):
class FakeNovaException_Remote(exception.NovaException):
msg_fmt = "some message"
def __unicode__(self):
return u"print the whole trace"
if six.PY3:
def __str__(self):
return "print the whole trace"
else:
def __unicode__(self):
return u"print the whole trace"
exc = FakeNovaException_Remote()
self.assertEqual(six.text_type(exc), u"print the whole trace")

View File

@ -43,6 +43,7 @@ deps = -r{toxinidir}/requirements.txt
commands =
find . -type f -name "*.pyc" -delete
python -m testtools.run \
nova.tests.unit.test_exception \
nova.tests.unit.db.test_db_api \
nova.tests.unit.test_versions