Commit 37cbaa4a authored by Mike Frysinger's avatar Mike Frysinger Committed by Commit Bot

grit: policy: sort policy_definitions output for stability

The policy logic sorts a bunch of its keys already to keep the output
stable, especially for unittests.  The policy_definitions section is
not currently sorted which leads to unittest failures on Python 3 as
it happens to iterate differently.  Sort the keys to fix it.

Bug: 983071
Test: `./grit/test_suite_all.py` passes
Change-Id: Iacd30d0edc2a597ada265b4b69664a8d19d9629c
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1755389Reviewed-by: default avatarNico Weber <thakis@chromium.org>
Commit-Queue: Mike Frysinger <vapier@chromium.org>
Cr-Commit-Position: refs/heads/master@{#687406}
parent 80738e4e
......@@ -151,13 +151,10 @@ class PolicyTemplatesJsonUnittest(unittest.TestCase):
"policy_definitions": [
{
"caption": "%s",
"features": {"can_be_recommended": true, "dynamic_refresh": true},
"name": "MainPolicy",
"tags": [],
"desc": "Th\xefP\xefs p\xf4P\xf4l\xefP\xefc\xfdP\xfd d\xf4\xe9P\xf4\xe9s st\xfcP\xfcff.",
"type": "main",
"example_value": true,
"supported_on": ["chrome_os:29-"],
"features": {"can_be_recommended": true, "dynamic_refresh": true},
"name": "MainPolicy",
"schema": {
"properties": {
"default_launch_container": {
......@@ -173,7 +170,10 @@ class PolicyTemplatesJsonUnittest(unittest.TestCase):
}
},
"type": "object"
}
},
"supported_on": ["chrome_os:29-"],
"tags": [],
"type": "main"
}
],
"policy_atomic_group_definitions": [
......
......@@ -242,7 +242,7 @@ class PolicyJson(skeleton_gatherer.SkeletonGatherer):
'''
for item_count, (item1) in enumerate(items, 1):
self._AddIndentedNontranslateableChunk(depth, "{\n")
keys = item1.keys()
keys = sorted(item1.keys())
for keys_count, (key) in enumerate(keys, 1):
if key == 'items':
self._AddIndentedNontranslateableChunk(depth + 1, "\"items\": [\n")
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment