X-Git-Url: https://git.madduck.net/etc/vim.git/blobdiff_plain/7e1c5b2ba6355f1a6916cf5545dc577cf2e6c727..728c56c986bc5aea4d9897d3fce3159f89991b8e:/tests/test_black.py diff --git a/tests/test_black.py b/tests/test_black.py index e512832..759bda5 100644 --- a/tests/test_black.py +++ b/tests/test_black.py @@ -17,6 +17,7 @@ ff = partial(black.format_file_in_place, line_length=ll, fast=True) fs = partial(black.format_str, line_length=ll) THIS_FILE = Path(__file__) THIS_DIR = THIS_FILE.parent +EMPTY_LINE = '# EMPTY LINE WITH WHITESPACE' + ' (this comment will be removed)' def dump_to_stderr(*output: str) -> str: @@ -33,6 +34,7 @@ def read_data(name: str) -> Tuple[str, str]: lines = test.readlines() result = _input for line in lines: + line = line.replace(EMPTY_LINE, '') if line.rstrip() == '# output': result = _output continue @@ -188,6 +190,14 @@ class BlackTestCase(unittest.TestCase): # black.assert_equivalent(source, actual) black.assert_stable(source, actual, line_length=ll) + @patch("black.dump_to_file", dump_to_stderr) + def test_fmtonoff(self) -> None: + source, expected = read_data('fmtonoff') + actual = fs(source) + self.assertFormatEqual(expected, actual) + black.assert_equivalent(source, actual) + black.assert_stable(source, actual, line_length=ll) + def test_report(self) -> None: report = black.Report() out_lines = []