Bug 1150818 - Part 1: Output mozinfo into a file. r=ted

This commit is contained in:
Hiroyuki Ikezoe 2015-08-20 15:30:00 -04:00
parent 8d8917564b
commit 70e8dfe6a4
2 changed files with 12 additions and 0 deletions

View File

@ -215,6 +215,11 @@ def find_and_update_from_json(*dirs):
return None
def output_to_file(path):
import json
with open(path, 'w') as f:
f.write(json.dumps(info));
update({})
# exports
@ -227,6 +232,7 @@ __all__ += [
'choices',
'update',
'find_and_update_from_json',
'output_to_file',
'StringVersion',
]

View File

@ -84,6 +84,12 @@ class TestMozinfo(unittest.TestCase):
self.assertEqual(mozinfo.find_and_update_from_json(), j)
self.assertEqual(mozinfo.info["foo"], "123456")
def test_output_to_file(self):
"""Test that mozinfo.output_to_file works."""
path = os.path.join(self.tempdir, "mozinfo.json")
mozinfo.output_to_file(path)
self.assertEqual(open(path).read(), json.dumps(mozinfo.info))
class TestStringVersion(unittest.TestCase):
def test_os_version_is_a_StringVersion(self):