當前位置: 首頁>>代碼示例>>Python>>正文


Python utils.Rule類代碼示例

本文整理匯總了Python中tests.utils.Rule的典型用法代碼示例。如果您正苦於以下問題:Python Rule類的具體用法?Python Rule怎麽用?Python Rule使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


在下文中一共展示了Rule類的8個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: test_from_path

 def test_from_path(self, mocker):
     match = object()
     get_new_command = object()
     load_source = mocker.patch(
         'thefuck.types.load_source',
         return_value=Mock(match=match,
                           get_new_command=get_new_command,
                           enabled_by_default=True,
                           priority=900,
                           requires_output=True))
     assert Rule.from_path(Path('/rules/bash.py')) \
            == Rule('bash', match, get_new_command, priority=900)
     load_source.assert_called_once_with('bash', '/rules/bash.py')
開發者ID:HengMrZ,項目名稱:thefuck,代碼行數:13,代碼來源:test_types.py

示例2: test_get_corrected_commands_with_rule_returns_command

 def test_get_corrected_commands_with_rule_returns_command(self):
     rule = Rule(get_new_command=lambda x: x.script + '!',
                 priority=100)
     assert (list(rule.get_corrected_commands(Command(script='test')))
             == [CorrectedCommand(script='test!', priority=100)])
開發者ID:ispiders,項目名稱:thefuck,代碼行數:5,代碼來源:test_types.py

示例3: test_isnt_match_when_rule_failed

 def test_isnt_match_when_rule_failed(self, capsys):
     rule = Rule('test', Mock(side_effect=OSError('Denied')),
                 requires_output=False)
     assert not rule.is_match(Command('ls'))
     assert capsys.readouterr()[1].split('\n')[0] == '[WARN] Rule test:'
開發者ID:ispiders,項目名稱:thefuck,代碼行數:5,代碼來源:test_types.py

示例4: test_is_match

 def test_is_match(self):
     rule = Rule('', lambda x: x.script == 'cd ..')
     assert rule.is_match(Command('cd ..'))
開發者ID:ispiders,項目名稱:thefuck,代碼行數:3,代碼來源:test_types.py

示例5: test_get_corrected_commands_with_rule_returns_list

 def test_get_corrected_commands_with_rule_returns_list(self):
     rule = Rule(get_new_command=lambda x: [x.script + '!', x.script + '@'],
                 priority=100)
     assert list(rule.get_corrected_commands(Command(script='test'))) \
            == [CorrectedCommand(script='test!', priority=100),
                CorrectedCommand(script='[email protected]', priority=200)]
開發者ID:DannyDebevec,項目名稱:thefuck,代碼行數:6,代碼來源:test_types.py

示例6: test_get_corrected_commands_with_rule_returns_list

 def test_get_corrected_commands_with_rule_returns_list(self):
     rule = Rule(get_new_command=lambda x: [x.script + "!", x.script + "@"], priority=100)
     assert list(rule.get_corrected_commands(Command(script="test"))) == [
         CorrectedCommand(script="test!", priority=100),
         CorrectedCommand(script="[email protected]", priority=200),
     ]
開發者ID:chishi2612,項目名稱:thefuck,代碼行數:6,代碼來源:test_types.py

示例7: test_isnt_match_when_rule_failed

 def test_isnt_match_when_rule_failed(self, capsys):
     rule = Rule("test", Mock(side_effect=OSError("Denied")), requires_output=False)
     assert not rule.is_match(Command("ls"))
     assert capsys.readouterr()[1].split("\n")[0] == "[WARN] Rule test:"
開發者ID:chishi2612,項目名稱:thefuck,代碼行數:4,代碼來源:test_types.py

示例8: test_is_match

 def test_is_match(self):
     rule = Rule("", lambda x: x.script == "cd ..")
     assert rule.is_match(Command("cd .."))
開發者ID:chishi2612,項目名稱:thefuck,代碼行數:3,代碼來源:test_types.py


注:本文中的tests.utils.Rule類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。