本文整理汇总了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;未经允许,请勿转载。 |
请发表评论