X-Git-Url: https://git.madduck.net/etc/vim.git/blobdiff_plain/42a3fe53319a8c02858c2a96989ed1339f84515a..2dfa69bb7fc1d310902ae565271d595d307f166b:/tests/test_black.py?ds=inline diff --git a/tests/test_black.py b/tests/test_black.py index 3418df9..191f4b8 100644 --- a/tests/test_black.py +++ b/tests/test_black.py @@ -400,6 +400,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_fmtonoff2(self) -> None: + source, expected = read_data("fmtonoff2") + actual = fs(source) + self.assertFormatEqual(expected, actual) + black.assert_equivalent(source, actual) + black.assert_stable(source, actual, line_length=ll) + @patch("black.dump_to_file", dump_to_stderr) def test_remove_empty_parentheses_after_class(self) -> None: source, expected = read_data("class_blank_parentheses") @@ -1205,6 +1213,28 @@ class BlackTestCase(unittest.TestCase): child.is_symlink.assert_called() self.assertEqual(child.is_symlink.call_count, 2) + def test_shhh_click(self) -> None: + try: + from click import _unicodefun # type: ignore + except ModuleNotFoundError: + self.skipTest("Incompatible Click version") + if not hasattr(_unicodefun, "_verify_python3_env"): + self.skipTest("Incompatible Click version") + # First, let's see if Click is crashing with a preferred ASCII charset. + with patch("locale.getpreferredencoding") as gpe: + gpe.return_value = "ASCII" + with self.assertRaises(RuntimeError): + _unicodefun._verify_python3_env() + # Now, let's silence Click... + black.patch_click() + # ...and confirm it's silent. + with patch("locale.getpreferredencoding") as gpe: + gpe.return_value = "ASCII" + try: + _unicodefun._verify_python3_env() + except RuntimeError as re: + self.fail(f"`patch_click()` failed, exception still raised: {re}") + if __name__ == "__main__": unittest.main(module="test_black")