X-Git-Url: https://git.madduck.net/etc/vim.git/blobdiff_plain/ba618a307a30a119b4fafe526ebf7d5f092ba981..0359b85b5800dd77f8f1cfaa88ca8ab8215df685:/tests/test_black.py diff --git a/tests/test_black.py b/tests/test_black.py index 089e043..96e6f1e 100644 --- a/tests/test_black.py +++ b/tests/test_black.py @@ -1286,6 +1286,17 @@ class BlackTestCase(BlackBaseTestCase): if nl == "\n": self.assertNotIn(b"\r\n", output) + def test_normalize_line_endings(self) -> None: + with TemporaryDirectory() as workspace: + test_file = Path(workspace) / "test.py" + for data, expected in ( + (b"c\r\nc\n ", b"c\r\nc\r\n"), + (b"l\nl\r\n ", b"l\nl\n"), + ): + test_file.write_bytes(data) + ff(test_file, write_back=black.WriteBack.YES) + self.assertEqual(test_file.read_bytes(), expected) + def test_assert_equivalent_different_asts(self) -> None: with self.assertRaises(AssertionError): black.assert_equivalent("{}", "None") @@ -1990,6 +2001,13 @@ class TestFileCollection: ) assert sorted(expected) == sorted(sources) + def test_nested_gitignore_directly_in_source_directory(self) -> None: + # https://github.com/psf/black/issues/2598 + path = Path(DATA_DIR / "nested_gitignore_tests") + src = Path(path / "root" / "child") + expected = [src / "a.py", src / "c.py"] + assert_collected_sources([src], expected) + def test_invalid_gitignore(self) -> None: path = THIS_DIR / "data" / "invalid_gitignore_tests" empty_config = path / "pyproject.toml"