提交 46c96800 编写于 作者: C Cleber Rosa

selftests/functional/test_json_variants.py: do not rely on the order of dict

The items of a dictionary are not ordered by default, and between
Python 2 and 3 they always come out different in my experience.

Since this test is trying out the representation of a JSON built from
dicts, the same applies.  Let's make the checks a bit more flexible
(and a bit less accurate to be honest) and check for the pieces of
info inside the JSON file content.
Signed-off-by: NCleber Rosa <crosa@redhat.com>
上级 557d0dfa
......@@ -21,14 +21,16 @@ class VariantsDumpLoadTests(unittest.TestCase):
os.chdir(basedir)
def test_variants_dump(self):
content = ('[{"paths": ["/run/*"], '
'"variant": [["/", []]], '
'"variant_id": null}]')
cmd_line = ('%s variants --json-variants-dump %s' %
(AVOCADO, self.variants_file))
process.run(cmd_line)
with open(self.variants_file, 'r') as file_obj:
self.assertEqual(file_obj.read(), content)
file_content = file_obj.read()
self.assertEqual(file_content[0:2], '[{')
self.assertIn('"paths": ["/run/*"]', file_content)
self.assertIn('"variant": [["/", []]]', file_content)
self.assertIn('"variant_id": null', file_content)
self.assertEqual(file_content[-2:], '}]')
def test_run_load(self):
content = ('[{"paths": ["/run/*"],'
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册