diff --git a/CHANGES.md b/CHANGES.md index 4b5a291c7b9..2961dbb320b 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -7,6 +7,10 @@ - Fix missing modules in self-contained binaries (#2466) - Fix missing toml extra used during installation (#2475) +### Tests + +- Fix patching of `io.TextIOWrapper` (#2489) + ## 21.8b0 ### _Black_ diff --git a/tests/test_black.py b/tests/test_black.py index 398a528bee9..9d590c1c03d 100644 --- a/tests/test_black.py +++ b/tests/test_black.py @@ -25,7 +25,7 @@ ) import pytest import unittest -from unittest.mock import patch, MagicMock +from unittest.mock import patch, MagicMock, Mock from parameterized import parameterized import click @@ -1689,7 +1689,9 @@ def test_reformat_one_with_stdin_and_existing_path(self) -> None: def test_reformat_one_with_stdin_empty(self) -> None: output = io.StringIO() - with patch("io.TextIOWrapper", lambda *args, **kwargs: output): + mock_io = Mock() + mock_io.TextIOWrapper.return_value = output + with patch.object(black, "io", mock_io): try: black.format_stdin_to_stdout( fast=True,