本文整理匯總了Python中workflow.workflow.Workflow.clear_settings方法的典型用法代碼示例。如果您正苦於以下問題:Python Workflow.clear_settings方法的具體用法?Python Workflow.clear_settings怎麽用?Python Workflow.clear_settings使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類workflow.workflow.Workflow
的用法示例。
在下文中一共展示了Workflow.clear_settings方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: WorkflowTests
# 需要導入模塊: from workflow.workflow import Workflow [as 別名]
# 或者: from workflow.workflow.Workflow import clear_settings [as 別名]
class WorkflowTests(unittest.TestCase):
def setUp(self):
self.libs = [os.path.join(os.path.dirname(__file__), "lib")]
self.wf = Workflow(libraries=self.libs)
self.account = "this-is-my-test-account"
self.password = "this-is-my-safe-password"
self.password2 = "this-is-my-other-safe-password"
self.search_items = [
("Test Item One", MATCH_STARTSWITH),
("test item two", MATCH_STARTSWITH),
("TwoExtraSpecialTests", MATCH_CAPITALS),
("this-is-a-test", MATCH_ATOM),
("the extra special trials", MATCH_INITIALS_STARTSWITH),
("not the extra special trials", MATCH_INITIALS_CONTAIN),
("intestinal fortitude", MATCH_SUBSTRING),
("the splits", MATCH_ALLCHARS),
("nomatch", 0),
]
self.search_items_diacritics = [
# search key, query
("Änderungen vorbehalten", "av"),
("Änderungen", "anderungen"),
("überwiegend bewolkt", "ub"),
("überwiegend", "uberwiegend"),
("Öffnungszeiten an Feiertagen", "offnungszeiten"),
("Öffnungszeiten an Feiertagen", "oaf"),
("Fußpilz", "fuss"),
("salé", "sale"),
]
def tearDown(self):
self.wf.clear_cache()
self.wf.clear_settings()
try:
self.wf.delete_password(self.account)
except PasswordNotFound:
pass
for dirpath in (self.wf.cachedir, self.wf.datadir):
if os.path.exists(dirpath):
shutil.rmtree(dirpath)
def test_item_creation(self):
"""XML generation"""
self.wf.add_item(
"title",
"subtitle",
"arg",
autocomplete="autocomplete",
valid=True,
uid="uid",
icon="icon.png",
icontype="fileicon",
type="file",
)
stdout = sys.stdout
sio = StringIO()
sys.stdout = sio
self.wf.send_feedback()
sys.stdout = stdout
output = sio.getvalue()
sio.close()
# pprint(output)
root = ET.fromstring(output)
item = list(root)[0]
self.assertEqual(item.attrib["uid"], "uid")
self.assertEqual(item.attrib["autocomplete"], "autocomplete")
self.assertEqual(item.attrib["valid"], "yes")
self.assertEqual(item.attrib["uid"], "uid")
title, subtitle, arg, icon = list(item)
self.assertEqual(title.text, "title")
self.assertEqual(title.tag, "title")
self.assertEqual(subtitle.text, "subtitle")
self.assertEqual(subtitle.tag, "subtitle")
self.assertEqual(arg.text, "arg")
self.assertEqual(arg.tag, "arg")
self.assertEqual(icon.text, "icon.png")
self.assertEqual(icon.tag, "icon")
self.assertEqual(icon.attrib["type"], "fileicon")
def test_item_creation_no_optionals(self):
"""XML generation (no optionals)"""
self.wf.add_item("title", valid=False)
stdout = sys.stdout
sio = StringIO()
sys.stdout = sio
self.wf.send_feedback()
sys.stdout = stdout
output = sio.getvalue()
sio.close()
# pprint(output)
root = ET.fromstring(output)
item = list(root)[0]
for key in ["uid", "arg", "autocomplete"]:
self.assertFalse(key in item.attrib)
self.assertEqual(item.attrib["valid"], "no")
title, subtitle = list(item)
self.assertEqual(title.text, "title")
self.assertEqual(title.tag, "title")
self.assertEqual(subtitle.text, None)
#.........這裏部分代碼省略.........
示例2: WorkflowTests
# 需要導入模塊: from workflow.workflow import Workflow [as 別名]
# 或者: from workflow.workflow.Workflow import clear_settings [as 別名]
class WorkflowTests(unittest.TestCase):
def setUp(self):
self.libs = [os.path.join(os.path.dirname(__file__), 'lib')]
self.wf = Workflow(libraries=self.libs)
self.account = 'this-is-my-test-account'
self.password = 'this-is-my-safe-password'
self.password2 = 'this-is-my-other-safe-password'
self.search_items = [
('Test Item One', MATCH_STARTSWITH),
('test item two', MATCH_STARTSWITH),
('TwoExtraSpecialTests', MATCH_CAPITALS),
('this-is-a-test', MATCH_ATOM),
('the extra special trials', MATCH_INITIALS_STARTSWITH),
('not the extra special trials', MATCH_INITIALS_CONTAIN),
('intestinal fortitude', MATCH_SUBSTRING),
('the splits', MATCH_ALLCHARS),
('nomatch', 0),
]
def tearDown(self):
self.wf.clear_cache()
self.wf.clear_settings()
try:
self.wf.delete_password(self.account)
except PasswordNotFound:
pass
for dirpath in (self.wf.cachedir, self.wf.datadir):
if os.path.exists(dirpath):
shutil.rmtree(dirpath)
def test_item_creation(self):
"""XML generation"""
self.wf.add_item('title', 'subtitle', 'arg',
autocomplete='autocomplete',
valid=True, uid='uid', icon='icon.png',
icontype='fileicon',
type='file')
stdout = sys.stdout
sio = StringIO()
sys.stdout = sio
self.wf.send_feedback()
sys.stdout = stdout
output = sio.getvalue()
sio.close()
# pprint(output)
root = ET.fromstring(output)
item = list(root)[0]
self.assertEqual(item.attrib['uid'], 'uid')
self.assertEqual(item.attrib['autocomplete'], 'autocomplete')
self.assertEqual(item.attrib['valid'], 'yes')
self.assertEqual(item.attrib['uid'], 'uid')
title, subtitle, arg, icon = list(item)
self.assertEqual(title.text, 'title')
self.assertEqual(title.tag, 'title')
self.assertEqual(subtitle.text, 'subtitle')
self.assertEqual(subtitle.tag, 'subtitle')
self.assertEqual(arg.text, 'arg')
self.assertEqual(arg.tag, 'arg')
self.assertEqual(icon.text, 'icon.png')
self.assertEqual(icon.tag, 'icon')
self.assertEqual(icon.attrib['type'], 'fileicon')
def test_item_creation_no_optionals(self):
"""XML generation (no optionals)"""
self.wf.add_item('title',
valid=False)
stdout = sys.stdout
sio = StringIO()
sys.stdout = sio
self.wf.send_feedback()
sys.stdout = stdout
output = sio.getvalue()
sio.close()
# pprint(output)
root = ET.fromstring(output)
item = list(root)[0]
for key in ['uid', 'arg', 'autocomplete']:
self.assertFalse(key in item.attrib)
self.assertEqual(item.attrib['valid'], 'no')
title, subtitle = list(item)
self.assertEqual(title.text, 'title')
self.assertEqual(title.tag, 'title')
self.assertEqual(subtitle.text, None)
tags = [elem.tag for elem in list(item)]
for tag in ['icon', 'arg']:
self.assert_(tag not in tags)
def test_additional_libs(self):
"""Additional libraries"""
for path in self.libs:
self.assert_(path in sys.path)
self.assertEqual(sys.path[0:len(self.libs)], self.libs)
import youcanimportme
def test_info_plist(self):
"""info.plist"""
self.assertEqual(self.wf.name, WORKFLOW_NAME)
self.assertEqual(self.wf.bundleid, BUNDLE_ID)
#.........這裏部分代碼省略.........