DATA_DIR,
DEFAULT_MODE,
DETERMINISTIC_HEADER,
+ PROJECT_ROOT,
PY36_VERSIONS,
THIS_DIR,
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")
"""
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."
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)
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.