BaseException.message is deprecated since Python 2.6
PEP 352 deprecated the message attribute of the BaseException class. Using the message attribute will result in warnings like this: DeprecationWarning: BaseException.message has been deprecated as of Python 2.6 Using unicode(exc) is the suggested replacement. Change-Id: Ibf3c56e4baa6ad83e2b95a948787e9d02cf074d4
This commit is contained in:
parent
f1ea8f42b6
commit
d1eab10aa5
@ -41,23 +41,23 @@ class ProcessExecutionErrorTest(utils.BaseTestCase):
|
||||
|
||||
def test_defaults(self):
|
||||
err = processutils.ProcessExecutionError()
|
||||
self.assertTrue('None\n' in err.message)
|
||||
self.assertTrue('code: -\n' in err.message)
|
||||
self.assertTrue('None\n' in unicode(err))
|
||||
self.assertTrue('code: -\n' in unicode(err))
|
||||
|
||||
def test_with_description(self):
|
||||
description = 'The Narwhal Bacons at Midnight'
|
||||
err = processutils.ProcessExecutionError(description=description)
|
||||
self.assertTrue(description in err.message)
|
||||
self.assertTrue(description in unicode(err))
|
||||
|
||||
def test_with_exit_code(self):
|
||||
exit_code = 0
|
||||
err = processutils.ProcessExecutionError(exit_code=exit_code)
|
||||
self.assertTrue(str(exit_code) in err.message)
|
||||
self.assertTrue(str(exit_code) in unicode(err))
|
||||
|
||||
def test_with_cmd(self):
|
||||
cmd = 'telinit'
|
||||
err = processutils.ProcessExecutionError(cmd=cmd)
|
||||
self.assertTrue(cmd in err.message)
|
||||
self.assertTrue(cmd in unicode(err))
|
||||
|
||||
def test_with_stdout(self):
|
||||
stdout = """
|
||||
@ -80,13 +80,13 @@ class ProcessExecutionErrorTest(utils.BaseTestCase):
|
||||
the Wielder of Wonder, with world's renown.
|
||||
""".strip()
|
||||
err = processutils.ProcessExecutionError(stdout=stdout)
|
||||
print(err.message)
|
||||
self.assertTrue('people-kings' in err.message)
|
||||
print(unicode(err))
|
||||
self.assertTrue('people-kings' in unicode(err))
|
||||
|
||||
def test_with_stderr(self):
|
||||
stderr = 'Cottonian library'
|
||||
err = processutils.ProcessExecutionError(stderr=stderr)
|
||||
self.assertTrue(stderr in str(err.message))
|
||||
self.assertTrue(stderr in unicode(err))
|
||||
|
||||
def test_retry_on_failure(self):
|
||||
fd, tmpfilename = tempfile.mkstemp()
|
||||
|
Loading…
x
Reference in New Issue
Block a user