本文整理汇总了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')
示例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)])
示例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:'
示例4: test_is_match
def test_is_match(self):
rule = Rule('', lambda x: x.script == 'cd ..')
assert rule.is_match(Command('cd ..'))
示例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)]
示例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),
]
示例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:"
示例8: test_is_match
def test_is_match(self):
rule = Rule("", lambda x: x.script == "cd ..")
assert rule.is_match(Command("cd .."))