File: test_nothing_formatter.py

package info (click to toggle)
python-flake8 7.1.1-3
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 1,212 kB
  • sloc: python: 6,592; sh: 21; makefile: 19
file content (31 lines) | stat: -rw-r--r-- 884 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
"""Tests for the Nothing formatter obbject."""
from __future__ import annotations

import argparse

from flake8.formatting import default
from flake8.violation import Violation


def options(**kwargs):
    """Create an argparse.Namespace instance."""
    kwargs.setdefault("color", "auto")
    kwargs.setdefault("output_file", None)
    kwargs.setdefault("tee", False)
    return argparse.Namespace(**kwargs)


def test_format_returns_nothing():
    """Verify Nothing.format returns None."""
    formatter = default.Nothing(options())
    error = Violation("code", "file.py", 1, 1, "text", "1")

    assert formatter.format(error) is None


def test_show_source_returns_nothing():
    """Verify Nothing.show_source returns None."""
    formatter = default.Nothing(options())
    error = Violation("code", "file.py", 1, 1, "text", "1")

    assert formatter.show_source(error) is None