forked from mirrors/gecko-dev
This patch was generated via: $ pyupgrade --py36-plus $(find taskcluster/taskgraph -name "*.py" -type f) $ autoflake --remove-all-unused-imports -i $(find taskcluster/taskgraph -name "*.py" -type f) The same set of commands are being applied to standalone taskgraph as well so they remain in sync. Differential Revision: https://phabricator.services.mozilla.com/D123234
50 lines
1.2 KiB
Python
50 lines
1.2 KiB
Python
# This Source Code Form is subject to the terms of the Mozilla Public
|
|
# License, v. 2.0. If a copy of the MPL was not distributed with this
|
|
# file, You can obtain one at http://mozilla.org/MPL/2.0/.
|
|
|
|
|
|
import unittest
|
|
from textwrap import dedent
|
|
|
|
from taskgraph.util import yaml
|
|
from mozunit import main, MockedOpen
|
|
|
|
|
|
class TestYaml(unittest.TestCase):
|
|
def test_load(self):
|
|
with MockedOpen(
|
|
{
|
|
"/dir1/dir2/foo.yml": dedent(
|
|
"""\
|
|
prop:
|
|
- val1
|
|
"""
|
|
)
|
|
}
|
|
):
|
|
|
|
self.assertEqual(
|
|
yaml.load_yaml("/dir1/dir2", "foo.yml"), {"prop": ["val1"]}
|
|
)
|
|
|
|
def test_key_order(self):
|
|
with MockedOpen(
|
|
{
|
|
"/dir1/dir2/foo.yml": dedent(
|
|
"""\
|
|
job:
|
|
foo: 1
|
|
bar: 2
|
|
xyz: 3
|
|
"""
|
|
)
|
|
}
|
|
):
|
|
self.assertEqual(
|
|
list(yaml.load_yaml("/dir1/dir2", "foo.yml")["job"].keys()),
|
|
["foo", "bar", "xyz"],
|
|
)
|
|
|
|
|
|
if __name__ == "__main__":
|
|
main()
|