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

Method test_piping_diff

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

Source from the content-addressed store, hash-verified

191 black.assert_stable(source, result.stdout, DEFAULT_MODE)
192
193 def test_piping_diff(self) -> None:
194 diff_header = re.compile(
195 r"(STDIN|STDOUT)\t\d\d\d\d-\d\d-\d\d \d\d:\d\d:\d\d\.\d\d\d\d\d\d"
196 r"\+\d\d:\d\d"
197 )
198 source, _ = read_data("cases", "expression.py")
199 expected, _ = read_data("cases", "expression.diff")
200 args = [
201 "-",
202 "--fast",
203 f"--line-length={black.DEFAULT_LINE_LENGTH}",
204 "--diff",
205 f"--config={EMPTY_CONFIG}",
206 ]
207 result = BlackRunner().invoke(
208 black.main, args, input=BytesIO(source.encode("utf-8"))
209 )
210 self.assertEqual(result.exit_code, 0)
211 actual = diff_header.sub(DETERMINISTIC_HEADER, result.stdout)
212 actual = actual.rstrip() + "\n" # the diff output has a trailing space
213 self.assertEqual(expected, actual)
214
215 def test_piping_diff_with_color(self) -> None:
216 source, _ = read_data("cases", "expression.py")

Callers

nothing calls this directly

Calls 2

read_dataFunction · 0.90
BlackRunnerClass · 0.85

Tested by

no test coverage detected