def setUp(self): self.collection.register(CommandHasChangesCheckRule())
def test_command_changes_negative(self): self.collection.register(CommandHasChangesCheckRule()) failure = 'test/command-check-failure.yml' bad_runner = ansiblelint.Runner(self.collection, failure, [], [], []) errs = bad_runner.run() self.assertEqual(2, len(errs))
def test_command_changes_positive(self): self.collection.register(CommandHasChangesCheckRule()) success = 'test/command-check-success.yml' good_runner = ansiblelint.Runner(self.collection, success, [], [], []) self.assertEqual([], good_runner.run())
) with pytest.raises(TypeError, match=expected_err): MatchError() @pytest.mark.parametrize( ('left_match_error', 'right_match_error'), ( # sorting by message (MatchError("z"), MatchError("a")), # filenames takes priority in sorting (MatchError("a", filename="b"), MatchError("a", filename="a")), # rule id partial-become > rule id no-changed-when ( MatchError(rule=BecomeUserWithoutBecomeRule()), MatchError(rule=CommandHasChangesCheckRule()), ), # details are taken into account (MatchError("a", details="foo"), MatchError("a", details="bar")), # columns are taken into account (MatchError("a", column=3), MatchError("a", column=1)), (MatchError("a", column=3), MatchError("a")), ), ) class TestMatchErrorCompare: def test_match_error_less_than(self, left_match_error, right_match_error): """Check 'less than' protocol implementation in MatchError.""" assert right_match_error < left_match_error def test_match_error_greater_than(self, left_match_error, right_match_error):