From 1aef18870f4546b3942002d1055cfc22777bce4d Mon Sep 17 00:00:00 2001 From: Antonin Bourguignon Date: Tue, 26 Feb 2013 11:45:41 +0100 Subject: [PATCH 1/2] [IMP] use assertEqual instead of assertTrue and fix a test bzr revid: abo@openerp.com-20130226104541-hmzla9y2sa3qfqgi --- openerp/addons/base/tests/test_res_config.py | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/openerp/addons/base/tests/test_res_config.py b/openerp/addons/base/tests/test_res_config.py index 0508aab67ee..5e12b951bf9 100644 --- a/openerp/addons/base/tests/test_res_config.py +++ b/openerp/addons/base/tests/test_res_config.py @@ -40,13 +40,13 @@ class test_res_config(common.TransactionCase): # Check types self.assertTrue(isinstance(res, tuple)), "The result of get_option_path() should be a tuple (got %s)" % type(res) - self.assertTrue(len(res) == 2), "The tuple should contain 2 elements (got %s)" % len(res) + self.assertEqual(len(res), 2), "The tuple should contain 2 elements (got %s)" % len(res) self.assertTrue(isinstance(res[0], basestring)), "The first element of the tuple should be a string (got %s)" % type(res[0]) self.assertTrue(isinstance(res[1], long)), "The second element of the tuple should be an long (got %s)" % type(res[1]) # Check returned values - self.assertTrue(res[0] == self.expected_path), "Result mismatch: expected %s, got %s" % (self.expected_path, res[0]) - self.assertTrue(res[1] == self.expected_action_id), "Result mismatch: expected %s, got %s" % (self.expected_action_id, res[1]) + self.assertEqual(res[0], self.expected_path) + self.assertEqual(res[1], self.expected_action_id) def test_10_get_option_name(self): """ The get_option_name() method should return a string """ @@ -56,7 +56,7 @@ class test_res_config(common.TransactionCase): self.assertTrue(isinstance(res, basestring)), "Result type mismatch: expected basestring, got %s" % type(res) # Check returned value - self.assertTrue(res == self.expected_name), "Result mismatch: expected %s, got %s" % (self.expected_name, res) + self.assertEqual(res, self.expected_name) def test_20_get_config_warning(self): """ The get_config_warning() method should return a RedirectWarning """ @@ -66,8 +66,8 @@ class test_res_config(common.TransactionCase): self.assertTrue(isinstance(res, openerp.exceptions.RedirectWarning)), "Result type mismatch: expected openerp.exceptions.RedirectWarning, got %s" % type(res) # Check returned value - self.assertTrue(res.args[0], self.expected_final_error_msg), "Result mismatch: expected %s, got %s" % (self.expected_final_error_msg, res.args[0]) - self.assertTrue(res.args[1], self.expected_action_id), "Result mismatch: expected %s, got %s" % (self.expected_action_id, res.args[1]) + self.assertEqual(res.args[0], self.expected_final_error_msg) + self.assertEqual(res.args[1], self.expected_action_id) def test_30_get_config_warning_wo_menu(self): """ The get_config_warning() method should return a Warning exception """ @@ -77,4 +77,4 @@ class test_res_config(common.TransactionCase): self.assertTrue(isinstance(res, openerp.exceptions.Warning)), "Result type mismatch: expected openerp.exceptions.Warning, got %s" % type(res) # Check returned value - self.assertTrue(res.args[0], self.expected_final_error_msg), "Result mismatch: expected %s, got %s" % (self.expected_final_error_msg_wo_menu, res.args[0]) + self.assertEqual(res.args[0], self.expected_final_error_msg_wo_menu) From e3bfbf8b9f486e438e3be8278b485d15671dd69c Mon Sep 17 00:00:00 2001 From: Antonin Bourguignon Date: Tue, 26 Feb 2013 11:58:32 +0100 Subject: [PATCH 2/2] [IMP] use assertIsInstance instead of assertTrue bzr revid: abo@openerp.com-20130226105832-xq3mbnml1iwzvg67 --- openerp/addons/base/tests/test_res_config.py | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/openerp/addons/base/tests/test_res_config.py b/openerp/addons/base/tests/test_res_config.py index 5e12b951bf9..44f3fd262cb 100644 --- a/openerp/addons/base/tests/test_res_config.py +++ b/openerp/addons/base/tests/test_res_config.py @@ -39,10 +39,10 @@ class test_res_config(common.TransactionCase): res = self.res_config.get_option_path(self.cr, self.uid, self.menu_xml_id, context=None) # Check types - self.assertTrue(isinstance(res, tuple)), "The result of get_option_path() should be a tuple (got %s)" % type(res) + self.assertIsInstance(res, tuple) self.assertEqual(len(res), 2), "The tuple should contain 2 elements (got %s)" % len(res) - self.assertTrue(isinstance(res[0], basestring)), "The first element of the tuple should be a string (got %s)" % type(res[0]) - self.assertTrue(isinstance(res[1], long)), "The second element of the tuple should be an long (got %s)" % type(res[1]) + self.assertIsInstance(res[0], basestring) + self.assertIsInstance(res[1], long) # Check returned values self.assertEqual(res[0], self.expected_path) @@ -53,7 +53,7 @@ class test_res_config(common.TransactionCase): res = self.res_config.get_option_name(self.cr, self.uid, self.full_field_name, context=None) # Check type - self.assertTrue(isinstance(res, basestring)), "Result type mismatch: expected basestring, got %s" % type(res) + self.assertIsInstance(res, basestring) # Check returned value self.assertEqual(res, self.expected_name) @@ -63,7 +63,7 @@ class test_res_config(common.TransactionCase): res = self.res_config.get_config_warning(self.cr, self.error_msg, context=None) # Check type - self.assertTrue(isinstance(res, openerp.exceptions.RedirectWarning)), "Result type mismatch: expected openerp.exceptions.RedirectWarning, got %s" % type(res) + self.assertIsInstance(res, openerp.exceptions.RedirectWarning) # Check returned value self.assertEqual(res.args[0], self.expected_final_error_msg) @@ -74,7 +74,7 @@ class test_res_config(common.TransactionCase): res = self.res_config.get_config_warning(self.cr, self.error_msg_wo_menu, context=None) # Check type - self.assertTrue(isinstance(res, openerp.exceptions.Warning)), "Result type mismatch: expected openerp.exceptions.Warning, got %s" % type(res) + self.assertIsInstance(res, openerp.exceptions.Warning) # Check returned value self.assertEqual(res.args[0], self.expected_final_error_msg_wo_menu)