exception.message -> str(exception)
authorLars Hupfeldt <lhn@hupfeldtit.dk>
Thu, 13 Feb 2014 19:28:09 +0000 (20:28 +0100)
committerLars Hupfeldt <lhn@hupfeldtit.dk>
Thu, 13 Feb 2014 19:28:09 +0000 (20:28 +0100)
jenkinsapi_tests/systests/test_parameterized_builds.py
jenkinsapi_tests/unittests/test_jenkins.py
jenkinsapi_tests/unittests/test_job.py
jenkinsapi_tests/unittests/test_job_multiconf.py
jenkinsapi_tests/unittests/test_requester.py

index 680feb4..205fc78 100644 (file)
@@ -88,7 +88,7 @@ class TestParameterizedBuilds(BaseSystemTest):
         with self.assertRaises(WillNotBuild) as na:
             job.invoke(build_params=params)
         expected_msg = 'A build with these parameters is already queued.'
-        self.assertEqual(na.exception.message, expected_msg)
+        self.assertEqual(str(na.exception), expected_msg)
 
 
 if __name__ == '__main__':
index fa39055..9066a3a 100644 (file)
@@ -252,7 +252,7 @@ class TestJenkins(unittest.TestCase):
         with self.assertRaises(JenkinsAPIException) as ar:
             J.create_job('job_new', None)
 
-        self.assertEquals(ar.exception.message, 'Cannot create job job_new')
+        self.assertEquals(str(ar.exception), 'Cannot create job job_new')
 
     @mock.patch.object(JenkinsBase, '_poll')
     @mock.patch.object(Jenkins, '_poll')
index 82e7e21..d8d401f 100644 (file)
@@ -91,7 +91,7 @@ class TestJob(unittest.TestCase):
             self.j._mk_json_from_build_parameters(build_params='bad parameter')
 
         self.assertEquals(
-            ar.exception.message, 'Build parameters must be a dict')
+            str(ar.exception), 'Build parameters must be a dict')
 
     def test__mk_json_from_build_parameters(self):
         params = {'param1': 'value1', 'param2': 'value2'}
@@ -105,7 +105,7 @@ class TestJob(unittest.TestCase):
             self.j.mk_json_from_build_parameters(build_params='bad parameter')
 
         self.assertEquals(
-            ar.exception.message, 'Build parameters must be a dict')
+            str(ar.exception), 'Build parameters must be a dict')
 
     @mock.patch.object(JenkinsBase, 'get_data', fakeGetData)
     def test_wrong_field__build_id_for_type(self):
index 335f741..b994bdd 100644 (file)
 #             self.j._mk_json_from_build_parameters(build_params='bad parameter')
 
 #         self.assertEquals(
-#             ar.exception.message, 'Build parameters must be a dict')
+#             str(ar.exception), 'Build parameters must be a dict')
 
 #     def test__mk_json_from_build_parameters(self):
 #         params = {'param1': 'value1', 'param2': 'value2'}
 #             self.j.mk_json_from_build_parameters(build_params='bad parameter')
 
 #         self.assertEquals(
-#             ar.exception.message, 'Build parameters must be a dict')
+#             str(ar.exception), 'Build parameters must be a dict')
 
 #     @mock.patch.object(JenkinsBase, 'get_data', fakeGetData)
 #     def test_wrong_field__build_id_for_type(self):
index 86502b4..521e1df 100644 (file)
@@ -31,7 +31,7 @@ class TestQueue(unittest.TestCase):
                 data=None,
                 headers=None
             )
-        self.assertTrue(na.exception.message == "Params must be a dict, got 'wrong'")
+        self.assertTrue(str(na.exception) == "Params must be a dict, got 'wrong'")
 
     def test_get_request_dict_correct_params(self):
         req = Requester('foo', 'bar')
@@ -55,7 +55,7 @@ class TestQueue(unittest.TestCase):
                 data=None,
                 headers='wrong'
             )
-        self.assertTrue(na.exception.message == "headers must be a dict, got 'wrong'")
+        self.assertTrue(str(na.exception) == "headers must be a dict, got 'wrong'")
 
     def test_get_request_dict_correct_headers(self):
         req = Requester('foo', 'bar')
@@ -127,7 +127,7 @@ class TestQueue(unittest.TestCase):
                 data=None
             )
 
-        self.assertTrue(ae.exception.message == "Unexpected type of parameter 'data': <type 'NoneType'>. Expected (str, dict)")
+        self.assertTrue(str(ae.exception) == "Unexpected type of parameter 'data': <type 'NoneType'>. Expected (str, dict)")
 
     @mock.patch.object(requests, 'post')
     def test_post_xml_and_confirm_status_some_xml(self, _post):
@@ -153,7 +153,7 @@ class TestQueue(unittest.TestCase):
                 data=None
             )
 
-        self.assertTrue(ae.exception.message == "Unexpected type of parameter 'data': <type 'NoneType'>. Expected (str, dict)")
+        self.assertTrue(str(ae.exception) == "Unexpected type of parameter 'data': <type 'NoneType'>. Expected (str, dict)")
 
     @mock.patch.object(requests, 'post')
     def test_post_and_confirm_status_some_data(self, _post):
@@ -182,8 +182,8 @@ class TestQueue(unittest.TestCase):
                 data='some data'
             )
 
-        print(ae.exception.message)
-        self.assertTrue(ae.exception.message == "Operation failed. url=None, data=some data, headers={'Content-Type': 'application/x-www-form-urlencoded'}, status=500, text=")
+        print(str(ae.exception))
+        self.assertTrue(str(ae.exception) == "Operation failed. url=None, data=some data, headers={'Content-Type': 'application/x-www-form-urlencoded'}, status=500, text=")
 
     @mock.patch.object(requests, 'get')
     def test_get_and_confirm_status(self, _get):
@@ -210,8 +210,8 @@ class TestQueue(unittest.TestCase):
                 params={'param': 'value'}
             )
 
-        print(ae.exception.message)
-        self.assertTrue(ae.exception.message == "Operation failed. url=None, headers=None, status=500, text=")
+        print(str(ae.exception))
+        self.assertTrue(str(ae.exception) == "Operation failed. url=None, headers=None, status=500, text=")
 
 if __name__ == "__main__":
     unittest.main()