Test running the codespell executable.
(tmp_path: Path, capsys: pytest.CaptureFixture[str])
| 1455 | |
| 1456 | |
| 1457 | def 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 | |
| 1488 | def test_args_from_file( |
nothing calls this directly
no test coverage detected
searching dependent graphs…