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

Method test_code_option_diff

tests/test_black.py:1880–1893  ·  view source on GitHub ↗

Test the code option when diff is passed.

(self)

Source from the content-addressed store, hash-verified

1878 self.compare_results(result, "", 1)
1879
1880 def test_code_option_diff(self) -> None:
1881 """Test the code option when diff is passed."""
1882 code = "print('hello world')"
1883 formatted = black.format_str(code, mode=DEFAULT_MODE)
1884 result_diff = diff(code, formatted, "STDIN", "STDOUT")
1885
1886 args = ["--diff", "--code", code]
1887 result = BlackRunner().invoke(black.main, args)
1888
1889 # Remove time from diff
1890 output = DIFF_TIME.sub("", result.output)
1891
1892 assert output == result_diff, "The output did not match the expected value."
1893 assert result.exit_code == 0, "The exit code is incorrect."
1894
1895 def test_code_option_color_diff(self) -> None:
1896 """Test the code option when color and diff are passed."""

Callers

nothing calls this directly

Calls 2

diffFunction · 0.90
BlackRunnerClass · 0.85

Tested by

no test coverage detected