Fix parameters of assertEqual are misplaced

Many assertEqual sentences don't follow assertEqual(expected, actual),
These misplaces have 2 impacts:
1, giving confusing messages when some tests failed.
2, mislead other developers, new test modules may follow these wrong pattern.

This patch fix all of them.

Change-Id: Ie9da006cc561e5266812db2bb1c03a624b5e844b
Closes-Bug: #1604213
This commit is contained in:
yan.haifeng 2016-07-22 11:48:19 +08:00
parent 7bff0fc012
commit 9c03983d78
2 changed files with 9 additions and 9 deletions

View File

@ -41,7 +41,7 @@ class TestBaseTestCase(testtools.TestCase):
tc._set_timeout()
env_get_mock.assert_called_once_with('OS_TEST_TIMEOUT', 0)
fixture_timeout_mock.assert_called_once_with(1, gentle=True)
self.assertEqual(fixture_mock.call_count, 1)
self.assertEqual(1, fixture_mock.call_count)
@mock.patch('os.environ.get')
def test_fake_logs_default(self, env_get_mock):
@ -77,7 +77,7 @@ class TestBaseTestCase(testtools.TestCase):
tc.setUp()
env_get_mock.assert_any_call('OS_LOG_CAPTURE')
env_get_mock.assert_any_call('OS_DEBUG')
self.assertEqual(fixture_mock.call_count, 5)
self.assertEqual(5, fixture_mock.call_count)
def test_mock_patch_cleanup_on_teardown(self):
# create an object and save its reference
@ -89,7 +89,7 @@ class TestBaseTestCase(testtools.TestCase):
# patch the object
mock.patch.object(obj, 'value').start()
self.assertNotEqual(obj.value, obj.backup)
self.assertNotEqual(obj.backup, obj.value)
# run a test case
loader = unittest.defaultTestLoader
@ -97,7 +97,7 @@ class TestBaseTestCase(testtools.TestCase):
suite.run(unittest.TestResult())
# check that mock patches are cleaned up
self.assertEqual(obj.value, obj.backup)
self.assertEqual(obj.backup, obj.value)
@mock.patch('os.environ')
def test_capture_output_disabled(self, mock_env):
@ -173,8 +173,8 @@ class TestTempFiles(base.BaseTestCase):
if not isinstance(raw_contents, six.text_type):
raw_contents = six.text_type(raw_contents,
encoding=raw_encoding)
self.assertEqual(raw_contents,
six.text_type(contents, encoding=raw_encoding))
self.assertEqual(six.text_type(contents, encoding=raw_encoding),
raw_contents)
def test_create_bad_encoding(self):
files = [["hrm", u'ಠ~ಠ', 'ascii']]

View File

@ -29,7 +29,7 @@ class TimeoutTestCase(testtools.TestCase):
tc.setUp()
env_get_mock.assert_called_once_with('OS_TEST_TIMEOUT', 0)
fixture_timeout_mock.assert_called_once_with(1, gentle=True)
self.assertEqual(fixture_mock.call_count, 1)
self.assertEqual(1, fixture_mock.call_count)
@mock.patch('os.environ.get')
@mock.patch.object(timeout.Timeout, 'useFixture')
@ -41,5 +41,5 @@ class TimeoutTestCase(testtools.TestCase):
tc = timeout.Timeout()
tc.setUp()
env_get_mock.assert_called_once_with('OS_TEST_TIMEOUT', 0)
self.assertEqual(fixture_timeout_mock.call_count, 0)
self.assertEqual(fixture_mock.call_count, 0)
self.assertEqual(0, fixture_timeout_mock.call_count)
self.assertEqual(0, fixture_mock.call_count)