MCPcopy Create free account
hub / github.com/codespell-project/codespell / test_stdin

Function test_stdin

codespell_lib/tests/test_basic.py:1457–1485  ·  view source on GitHub ↗

Test running the codespell executable.

(tmp_path: Path, capsys: pytest.CaptureFixture[str])

Source from the content-addressed store, hash-verified

1455
1456
1457def test_stdin(tmp_path: Path, capsys: pytest.CaptureFixture[str]) -> None:
1458 """Test running the codespell executable."""
1459 input_file_lines = 4
1460 text = ""
1461 for _ in range(input_file_lines):
1462 text += "abandonned\n"
1463 for single_line_per_error in (True, False):
1464 args: tuple[str, ...] = ()
1465 if single_line_per_error:
1466 args = ("--stdin-single-line",)
1467 # we expect 'input_file_lines' number of lines with
1468 # --stdin-single-line and input_file_lines * 2 lines without it
1469 assert run_codespell_stdin(
1470 text, args=args, cwd=tmp_path
1471 ) == input_file_lines * (2 - int(single_line_per_error))
1472
1473 with FakeStdin("Thsi is a line"):
1474 result = cs.main("-", "-w", std=True)
1475 assert isinstance(result, tuple)
1476 code, stdout, _ = result
1477 assert stdout == "---\nThis is a line"
1478 assert code == 0
1479
1480 with FakeStdin("Thsi is a line"):
1481 result = cs.main("-", "--stdin-single-line", std=True)
1482 assert isinstance(result, tuple)
1483 code, stdout, _ = result
1484 assert stdout == "1: Thsi ==> This\n"
1485 assert code == 1
1486
1487
1488def test_args_from_file(

Callers

nothing calls this directly

Calls 3

run_codespell_stdinFunction · 0.85
FakeStdinFunction · 0.85
mainMethod · 0.80

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…