X-Git-Url: https://git.madduck.net/etc/vim.git/blobdiff_plain/be16cfa0353f33adf0ee5f026d9b46f9ca6ac7ac..017aafea992ca1c6d7af45d3013af7ddb7fda12a:/tests/test_black.py diff --git a/tests/test_black.py b/tests/test_black.py index 5262c0e..42ac119 100644 --- a/tests/test_black.py +++ b/tests/test_black.py @@ -6,6 +6,7 @@ from concurrent.futures import ThreadPoolExecutor from contextlib import contextmanager from dataclasses import replace import inspect +import io from io import BytesIO import os from pathlib import Path @@ -1682,6 +1683,20 @@ class BlackTestCase(BlackBaseTestCase): # __BLACK_STDIN_FILENAME__ should have been stripped report.done.assert_called_with(expected, black.Changed.YES) + def test_reformat_one_with_stdin_empty(self) -> None: + output = io.StringIO() + with patch("io.TextIOWrapper", lambda *args, **kwargs: output): + try: + black.format_stdin_to_stdout( + fast=True, + content="", + write_back=black.WriteBack.YES, + mode=DEFAULT_MODE, + ) + except io.UnsupportedOperation: + pass # StringIO does not support detach + assert output.getvalue() == "" + def test_gitignore_exclude(self) -> None: path = THIS_DIR / "data" / "include_exclude_tests" include = re.compile(r"\.pyi?$")