MCPcopy Create free account
hub / github.com/psf/black / test_code_option_diff

Method test_code_option_diff

tests/test_black.py:1824–1837  ·  view source on GitHub ↗

Test the code option when diff is passed.

(self)

Source from the content-addressed store, hash-verified

1822 self.compare_results(result, "", 1)
1823
1824 def test_code_option_diff(self) -> None:
1825 """Test the code option when diff is passed."""
1826 code = "print('hello world')"
1827 formatted = black.format_str(code, mode=DEFAULT_MODE)
1828 result_diff = diff(code, formatted, "STDIN", "STDOUT")
1829
1830 args = ["--diff", "--code", code]
1831 result = CliRunner().invoke(black.main, args)
1832
1833 # Remove time from diff
1834 output = DIFF_TIME.sub("", result.output)
1835
1836 assert output == result_diff, "The output did not match the expected value."
1837 assert result.exit_code == 0, "The exit code is incorrect."
1838
1839 def test_code_option_color_diff(self) -> None:
1840 """Test the code option when color and diff are passed."""

Callers

nothing calls this directly

Calls 1

diffFunction · 0.90

Tested by

no test coverage detected