X-Git-Url: https://git.madduck.net/etc/vim.git/blobdiff_plain/3500e1cda5bef73ddc7eaf79be6c67c918738936..cbf5401efff0524f7395c5fb81551de75b17c89e:/tests/test_black.py diff --git a/tests/test_black.py b/tests/test_black.py index f25db1b..5647a00 100644 --- a/tests/test_black.py +++ b/tests/test_black.py @@ -50,6 +50,7 @@ from tests.util import ( DATA_DIR, DEFAULT_MODE, DETERMINISTIC_HEADER, + PROJECT_ROOT, PY36_VERSIONS, THIS_DIR, BlackBaseTestCase, @@ -805,6 +806,10 @@ class BlackTestCase(BlackBaseTestCase): self.assertEqual(black.get_features_used(node), set()) node = black.lib2to3_parse(expected) self.assertEqual(black.get_features_used(node), set()) + node = black.lib2to3_parse("lambda a, /, b: ...") + 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}) def test_get_future_imports(self) -> None: node = black.lib2to3_parse("\n") @@ -1508,9 +1513,11 @@ class BlackTestCase(BlackBaseTestCase): """ with patch.object(black, "parse_pyproject_toml", return_value={}) as parse: args = ["--code", "print"] - CliRunner().invoke(black.main, args) + # This is the only directory known to contain a pyproject.toml + with change_directory(PROJECT_ROOT): + CliRunner().invoke(black.main, args) + pyproject_path = Path(Path.cwd(), "pyproject.toml").resolve() - pyproject_path = Path(Path().cwd(), "pyproject.toml").resolve() assert ( len(parse.mock_calls) >= 1 ), "Expected config parse to be called with the current directory." @@ -1525,7 +1532,7 @@ class BlackTestCase(BlackBaseTestCase): Test that the code option finds the pyproject.toml in the parent directory. """ with patch.object(black, "parse_pyproject_toml", return_value={}) as parse: - with change_directory(Path("tests")): + with change_directory(THIS_DIR): args = ["--code", "print"] CliRunner().invoke(black.main, args) @@ -2014,7 +2021,9 @@ with open(black.__file__, "r", encoding="utf-8") as _bf: black_source_lines = _bf.readlines() -def tracefunc(frame: types.FrameType, event: str, arg: Any) -> Callable: +def tracefunc( + frame: types.FrameType, event: str, arg: Any +) -> Callable[[types.FrameType, str, Any], Any]: """Show function calls `from black/__init__.py` as they happen. Register this with `sys.settrace()` in a test you're debugging.