# test.govlab/quality/core/parsers/tool.pylint.parser.test.ts

> 32 lines of code and 0 definitions.

Tree: Codebase Testing
Language: typescript
Canonical: https://banes-lab.com/anatomy/testing#file-testing-test-govlab-quality-core-parsers-tool-pylint-parser-test-ts
Source text: https://banes-lab.com/source/testing/test.govlab/quality/core/parsers/tool.pylint.parser.test.ts.txt

Listed in [test.govlab/quality/core/parsers](https://banes-lab.com/api/source/testing/test.govlab/quality/core/parsers.md), after [test.govlab/quality/core/parsers/tool.phpmd.parser.test.ts](https://banes-lab.com/source/testing/test.govlab/quality/core/parsers/tool.phpmd.parser.test.ts.md) and before [test.govlab/quality/core/parsers/tool.revive.parser.test.ts](https://banes-lab.com/source/testing/test.govlab/quality/core/parsers/tool.revive.parser.test.ts.md).

## Contained in

- [test.govlab/quality/core/parsers](https://banes-lab.com/anatomy/testing/folder-testing-test-govlab-quality-core-parsers.md)

## Source

```typescript
import { describe, expect, it } from "vitest";
import { parsePylintOutput } from "@govlab/quality/core/parsers/tool.pylint.parser.ts";

const EXPECTED_COUNT = 2;

const RECORDED =
    '[{"column":0,"line":1,"message":"Missing module docstring","message-id":"C0114","path":"bad.py","symbol":"missing-module-docstring","type":"convention"},' +
    '{"column":0,"line":4,"message":"Too many arguments (6/5)","message-id":"R0913","path":"bad.py","symbol":"too-many-arguments","type":"refactor"}]';

describe("parsePylintOutput", () => {
    it("maps each message to a gating (advisory:false) error finding keyed by symbol, 1-basing the column", () => {
        const findings = parsePylintOutput(RECORDED, "python", false);
        expect(findings).toHaveLength(EXPECTED_COUNT);
        expect(findings[0]).toMatchObject({
            advisory: false,
            column: 1,
            ecosystem: "python",
            file: "bad.py",
            line: 1,
            ruleId: "missing-module-docstring",
            severity: "error",
            tool: "pylint",
        });
        expect(findings[1]).toMatchObject({ advisory: false, ruleId: "too-many-arguments", severity: "error" });
    });

    it("marks every finding advisory (non-gating) but still an error when pylint runs unelected", () => {
        const findings = parsePylintOutput(RECORDED, "python", true);
        expect(findings.every((finding) => finding.advisory && finding.severity === "error")).toBe(true);
    });

    it("returns [] on empty or non-array output", () => {
        expect(parsePylintOutput("", "python", false)).toEqual([]);
        expect(parsePylintOutput("[]", "python", false)).toEqual([]);
        expect(parsePylintOutput("not json", "python", false)).toEqual([]);
    });
});
```
