本文整理匯總了Python中mozprofile.profile.Profile.clean_preferences方法的典型用法代碼示例。如果您正苦於以下問題:Python Profile.clean_preferences方法的具體用法?Python Profile.clean_preferences怎麽用?Python Profile.clean_preferences使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類mozprofile.profile.Profile
的用法示例。
在下文中一共展示了Profile.clean_preferences方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: test_magic_markers
# 需要導入模塊: from mozprofile.profile import Profile [as 別名]
# 或者: from mozprofile.profile.Profile import clean_preferences [as 別名]
def test_magic_markers(self):
"""ensure our magic markers are working"""
profile = Profile()
prefs_file = os.path.join(profile.profile, 'user.js')
# we shouldn't have any initial preferences
initial_prefs = Preferences.read_prefs(prefs_file)
self.assertFalse(initial_prefs)
initial_prefs = file(prefs_file).read().strip()
self.assertFalse(initial_prefs)
# add some preferences
prefs1 = [("browser.startup.homepage", "http://planet.mozilla.org/"),
("zoom.minPercent", 30)]
profile.set_preferences(prefs1)
self.assertEqual(prefs1, Preferences.read_prefs(prefs_file))
lines = file(prefs_file).read().strip().splitlines()
self.assertTrue(bool([line for line in lines
if line.startswith('#MozRunner Prefs Start')]))
self.assertTrue(bool([line for line in lines
if line.startswith('#MozRunner Prefs End')]))
# add some more preferences
prefs2 = [("zoom.maxPercent", 300),
("webgl.verbose", 'false')]
profile.set_preferences(prefs2)
self.assertEqual(prefs1 + prefs2, Preferences.read_prefs(prefs_file))
lines = file(prefs_file).read().strip().splitlines()
self.assertTrue(len([line for line in lines
if line.startswith('#MozRunner Prefs Start')]) == 2)
self.assertTrue(len([line for line in lines
if line.startswith('#MozRunner Prefs End')]) == 2)
# now clean it up
profile.clean_preferences()
final_prefs = Preferences.read_prefs(prefs_file)
self.assertFalse(final_prefs)
lines = file(prefs_file).read().strip().splitlines()
self.assertTrue('#MozRunner Prefs Start' not in lines)
self.assertTrue('#MozRunner Prefs End' not in lines)