This commit is contained in:
@@ -45,6 +45,7 @@ class SpaceIndentation(unittest.TestCase):
|
|||||||
"prettier in package.json": ("package.json", '{"prettier": {"useTabs": false}}\n'),
|
"prettier in package.json": ("package.json", '{"prettier": {"useTabs": false}}\n'),
|
||||||
"biome": ("biome.jsonc", '{"formatter": {"indentStyle": "space"}}\n'),
|
"biome": ("biome.jsonc", '{"formatter": {"indentStyle": "space"}}\n'),
|
||||||
"a nested editorconfig": ("src__.editorconfig", "indent_style = space\n"),
|
"a nested editorconfig": ("src__.editorconfig", "indent_style = space\n"),
|
||||||
|
"an editorconfig two folders down": ("src__web__.editorconfig", "indent_style = space\n"),
|
||||||
}
|
}
|
||||||
for label, (name, text) in settings.items():
|
for label, (name, text) in settings.items():
|
||||||
with self.subTest(label):
|
with self.subTest(label):
|
||||||
@@ -64,6 +65,26 @@ class SpaceIndentation(unittest.TestCase):
|
|||||||
def test_stays_silent_where_tabs_are_as_many_as_spaces(self):
|
def test_stays_silent_where_tabs_are_as_many_as_spaces(self):
|
||||||
self.assertIsNone(space_indented(self.checkout(**{"a.py": SPACED, "b.py": TABBED})))
|
self.assertIsNone(space_indented(self.checkout(**{"a.py": SPACED, "b.py": TABBED})))
|
||||||
|
|
||||||
|
def test_sums_the_tabbed_lines_of_every_file(self):
|
||||||
|
self.assertIsNone(space_indented(self.checkout(**{"a.py": SPACED, "b.py": SPACED, "c.py": TABBED, "d.py": TABBED, "e.py": TABBED})))
|
||||||
|
|
||||||
|
def test_skips_a_tracked_file_that_is_gone_from_the_disk(self):
|
||||||
|
root = self.checkout(**{"a.py": SPACED, "gone.py": SPACED})
|
||||||
|
(root / "gone.py").unlink()
|
||||||
|
self.assertEqual(space_indented(root), SpaceIndented(spaced=2, tabbed=0))
|
||||||
|
|
||||||
|
def test_reads_a_file_that_is_not_utf8(self):
|
||||||
|
root = self.checkout(**{"a.py": ""})
|
||||||
|
(root / "a.py").write_bytes(b"\xff\xfe\n x\n y\n")
|
||||||
|
self.assertEqual(space_indented(root), SpaceIndented(spaced=2, tabbed=0))
|
||||||
|
|
||||||
|
@unittest.skipIf(os.geteuid() == 0, "root reads any file")
|
||||||
|
def test_names_a_file_it_cannot_read(self):
|
||||||
|
root = self.checkout(**{"a.py": SPACED})
|
||||||
|
(root / "a.py").chmod(0)
|
||||||
|
self.addCleanup((root / "a.py").chmod, 0o644)
|
||||||
|
self.assertEqual(space_indented(root), Failure(f"cannot read a.py: [Errno 13] Permission denied: '{root}/a.py'"))
|
||||||
|
|
||||||
def test_says_why_it_cannot_read_a_checkout(self):
|
def test_says_why_it_cannot_read_a_checkout(self):
|
||||||
self.assertIsInstance(space_indented(pathlib.Path("/nonexistent-checkout")), Failure)
|
self.assertIsInstance(space_indented(pathlib.Path("/nonexistent-checkout")), Failure)
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user