X-Git-Url: https://git.madduck.net/etc/vim.git/blobdiff_plain/3083f4470bba6838d0ad59e9748f45a7621623b5..dc90d4951f66ac665582159537b902017d9a0361:/tests/test_black.py diff --git a/tests/test_black.py b/tests/test_black.py index 468f00f..8726cc1 100644 --- a/tests/test_black.py +++ b/tests/test_black.py @@ -810,6 +810,14 @@ class BlackTestCase(BlackBaseTestCase): self.assertEqual(black.get_features_used(node), {Feature.POS_ONLY_ARGUMENTS}) node = black.lib2to3_parse("def fn(a, /, b): ...") self.assertEqual(black.get_features_used(node), {Feature.POS_ONLY_ARGUMENTS}) + node = black.lib2to3_parse("def fn(): yield a, b") + self.assertEqual(black.get_features_used(node), set()) + node = black.lib2to3_parse("def fn(): return a, b") + self.assertEqual(black.get_features_used(node), set()) + node = black.lib2to3_parse("def fn(): yield *b, c") + self.assertEqual(black.get_features_used(node), {Feature.UNPACKING_ON_FLOW}) + node = black.lib2to3_parse("def fn(): return a, *b, c") + self.assertEqual(black.get_features_used(node), {Feature.UNPACKING_ON_FLOW}) def test_get_features_used_for_future_flags(self) -> None: for src, features in [ @@ -1584,6 +1592,16 @@ class BlackTestCase(BlackBaseTestCase): exc_info.match("Cannot parse: 2:0: EOF in multi-line statement") + def test_equivalency_ast_parse_failure_includes_error(self) -> None: + with pytest.raises(AssertionError) as err: + black.assert_equivalent("a«»a = 1", "a«»a = 1") + + err.match("--safe") + # Unfortunately the SyntaxError message has changed in newer versions so we + # can't match it directly. + err.match("invalid character") + err.match(r"\(, line 1\)") + class TestCaching: def test_cache_broken_file(self) -> None: