diff options
author | Doug Hellmann <doug@doughellmann.com> | 2018-06-07 17:50:37 -0400 |
---|---|---|
committer | Doug Hellmann <doug@doughellmann.com> | 2018-06-07 17:51:28 -0400 |
commit | e48431192375bbace0adc896b9c4de3a9cd00b34 (patch) | |
tree | c16cdad852738314707ce9e03cd86187ab2bef13 | |
parent | 1cf00a5cc9c095071d18137c44f2722d0e20d84e (diff) | |
download | python-glanceclient-e48431192375bbace0adc896b9c4de3a9cd00b34.tar.gz |
update shell tests to not rely on the serialization order of a dict
Under python 3 with ordering randomized we cannot depend on the JSON
output matching exactly. Instead we de-serialize the data structure
that was written and compare the structures, which will always match.
Change-Id: I134b62413a7cde25f3efda6a2452c1e3d11d41d0
Signed-off-by: Doug Hellmann <doug@doughellmann.com>
-rw-r--r-- | glanceclient/tests/unit/test_shell.py | 16 |
1 files changed, 8 insertions, 8 deletions
diff --git a/glanceclient/tests/unit/test_shell.py b/glanceclient/tests/unit/test_shell.py index ce2fec3..0f15007 100644 --- a/glanceclient/tests/unit/test_shell.py +++ b/glanceclient/tests/unit/test_shell.py @@ -799,10 +799,10 @@ class ShellCacheSchemaTest(testutils.TestCase): open.mock_calls[0]) self.assertEqual(mock.call(self.cache_files[1], 'w'), open.mock_calls[4]) - self.assertEqual(mock.call().write(json.dumps(schema_odict)), - open.mock_calls[2]) - self.assertEqual(mock.call().write(json.dumps(schema_odict)), - open.mock_calls[6]) + actual = json.loads(open.mock_calls[2][1][0]) + self.assertEqual(schema_odict, actual) + actual = json.loads(open.mock_calls[6][1][0]) + self.assertEqual(schema_odict, actual) @mock.patch('six.moves.builtins.open', new=mock.mock_open(), create=True) @mock.patch('os.path.exists', side_effect=[True, False, False, False]) @@ -822,10 +822,10 @@ class ShellCacheSchemaTest(testutils.TestCase): open.mock_calls[0]) self.assertEqual(mock.call(self.cache_files[1], 'w'), open.mock_calls[4]) - self.assertEqual(mock.call().write(json.dumps(schema_odict)), - open.mock_calls[2]) - self.assertEqual(mock.call().write(json.dumps(schema_odict)), - open.mock_calls[6]) + actual = json.loads(open.mock_calls[2][1][0]) + self.assertEqual(schema_odict, actual) + actual = json.loads(open.mock_calls[6][1][0]) + self.assertEqual(schema_odict, actual) @mock.patch('six.moves.builtins.open', new=mock.mock_open(), create=True) @mock.patch('os.path.exists', return_value=True) |