本文整理汇总了Python中mozprofile.prefs.Preferences.write方法的典型用法代码示例。如果您正苦于以下问题:Python Preferences.write方法的具体用法?Python Preferences.write怎么用?Python Preferences.write使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类mozprofile.prefs.Preferences
的用法示例。
在下文中一共展示了Preferences.write方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_prefs_write
# 需要导入模块: from mozprofile.prefs import Preferences [as 别名]
# 或者: from mozprofile.prefs.Preferences import write [as 别名]
def test_prefs_write(self):
"""test that the Preferences.write() method correctly serializes preferences"""
_prefs = {'browser.startup.homepage': "http://planet.mozilla.org",
'zoom.minPercent': 30,
'zoom.maxPercent': 300}
# make a Preferences manager with the testing preferences
preferences = Preferences(_prefs)
# write them to a temporary location
path = None
read_prefs = None
try:
with mozfile.NamedTemporaryFile(suffix='.js', delete=False) as f:
path = f.name
preferences.write(f, _prefs)
# read them back and ensure we get what we put in
read_prefs = dict(Preferences.read_prefs(path))
finally:
# cleanup
if path and os.path.exists(path):
os.remove(path)
self.assertEqual(read_prefs, _prefs)