MCPcopy
hub / github.com/psf/black / test_skip_source_first_line

Method test_skip_source_first_line

tests/test_black.py:378–389  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

376 black.assert_stable(source, not_normalized, mode=mode)
377
378 def test_skip_source_first_line(self) -> None:
379 source, _ = read_data("miscellaneous", "invalid_header")
380 tmp_file = Path(black.dump_to_file(source))
381 # Full source should fail (invalid syntax at header)
382 self.invokeBlack([str(tmp_file), "--diff", "--check"], exit_code=123)
383 # So, skipping the first line should work
384 result = BlackRunner().invoke(
385 black.main, [str(tmp_file), "-x", f"--config={EMPTY_CONFIG}"]
386 )
387 self.assertEqual(result.exit_code, 0)
388 actual = tmp_file.read_text(encoding="utf-8")
389 self.assertFormatEqual(source, actual)
390
391 def test_skip_source_first_line_when_mixing_newlines(self) -> None:
392 code_mixing_newlines = b"Header will be skipped\r\ni = [1,2,3]\nj = [1,2,3]\n"

Callers

nothing calls this directly

Calls 3

read_dataFunction · 0.90
BlackRunnerClass · 0.85
assertFormatEqualMethod · 0.80

Tested by

no test coverage detected