Skip to content

Commit

Permalink
Test that Blackd also skips first line correctly
Browse files Browse the repository at this point in the history
Simliarly to the Black tests, we first compare that Blackd fails when
the first line is invalid Python syntax and then check that the result
is the expected when tha flag is activated

Signed-off-by: Antonio Ossa Guerra <[email protected]>
  • Loading branch information
aaossa committed Oct 6, 2022
1 parent 02d1d17 commit 6177cb3
Showing 1 changed file with 14 additions and 0 deletions.
14 changes: 14 additions & 0 deletions tests/test_blackd.py
Original file line number Diff line number Diff line change
Expand Up @@ -177,6 +177,20 @@ async def test_blackd_invalid_line_length(self) -> None:
)
self.assertEqual(response.status, 400)

@unittest_run_loop
async def test_blackd_skip_first_source_line(self) -> None:
invalid_first_line = b"Header will be skipped\r\ni = [1,2,3]\nj = [1,2,3]\n"
expected_result = b"Header will be skipped\r\ni = [1, 2, 3]\nj = [1, 2, 3]\n"
response = await self.client.post("/", data=invalid_first_line)
self.assertEqual(response.status, 400)
response = await self.client.post(
"/",
data=invalid_first_line,
headers={blackd.SKIP_SOURCE_FIRST_LINE: "true"},
)
self.assertEqual(response.status, 200)
self.assertEqual(await response.read(), expected_result)

@unittest_run_loop
async def test_blackd_preview(self) -> None:
response = await self.client.post(
Expand Down

0 comments on commit 6177cb3

Please sign in to comment.