From d1eab10aa5c314e51d04a78d89ec1ba945d0b33c Mon Sep 17 00:00:00 2001 From: Johannes Erdfelt <johannes.erdfelt@rackspace.com> Date: Fri, 26 Jul 2013 15:16:13 +0000 Subject: [PATCH] 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 --- tests/unit/test_processutils.py | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/tests/unit/test_processutils.py b/tests/unit/test_processutils.py index 7c6e11c..8a14eaf 100644 --- a/tests/unit/test_processutils.py +++ b/tests/unit/test_processutils.py @@ -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()