Example #1
0
def test_yamllint_ok():
    with tempfile.NamedTemporaryFile() as fp:
        fp.write(YAMLLINT_TEST_FILE_OK)
        fp.flush()

        linter = linters.YamlLinter()
        result = list(linter.check_files(fp.name))
        assert result == []
Example #2
0
def test_yamllint_fail():
    with tempfile.NamedTemporaryFile() as fp:
        fp.write(YAMLLINT_TEST_FILE_FAIL)
        fp.flush()

        linter = linters.YamlLinter()
        result = list(linter.check_files(fp.name))

        expected = [
            '{0}:1:1: [error] too many blank lines (1 > 0) (empty-lines)',
            '{0}:4:7: [error] too many spaces after hyphen (hyphens)',
        ]
        expected = [s.format(fp.name) for s in expected]
        assert sorted(result) == sorted(expected)