def __init__(self) -> None:
self.default_map: Dict[str, Any] = {}
+ self.params: Dict[str, Any] = {}
# Dummy root, since most of the tests don't care about it
self.obj: Dict[str, Any] = {"root": PROJECT_ROOT}
self.assertEqual(config["exclude"], r"\.pyi?$")
self.assertEqual(config["include"], r"\.py?$")
+ def test_read_pyproject_toml_from_stdin(self) -> None:
+ with TemporaryDirectory() as workspace:
+ root = Path(workspace)
+
+ src_dir = root / "src"
+ src_dir.mkdir()
+
+ src_pyproject = src_dir / "pyproject.toml"
+ src_pyproject.touch()
+
+ test_toml_file = THIS_DIR / "test.toml"
+ src_pyproject.write_text(test_toml_file.read_text())
+
+ src_python = src_dir / "foo.py"
+ src_python.touch()
+
+ fake_ctx = FakeContext()
+ fake_ctx.params["src"] = ("-",)
+ fake_ctx.params["stdin_filename"] = str(src_python)
+
+ with change_directory(root):
+ black.read_pyproject_toml(fake_ctx, FakeParameter(), None)
+
+ config = fake_ctx.default_map
+ self.assertEqual(config["verbose"], "1")
+ self.assertEqual(config["check"], "no")
+ self.assertEqual(config["diff"], "y")
+ self.assertEqual(config["color"], "True")
+ self.assertEqual(config["line_length"], "79")
+ self.assertEqual(config["target_version"], ["py36", "py37", "py38"])
+ self.assertEqual(config["exclude"], r"\.pyi?$")
+ self.assertEqual(config["include"], r"\.py?$")
+
@pytest.mark.incompatible_with_mypyc
def test_find_project_root(self) -> None:
with TemporaryDirectory() as workspace: