Skip to content

Commit

Permalink
Merge 172a496 into 2446941
Browse files Browse the repository at this point in the history
  • Loading branch information
csurfer committed Apr 21, 2018
2 parents 2446941 + 172a496 commit 3f72197
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 5 deletions.
6 changes: 1 addition & 5 deletions black.py
Original file line number Diff line number Diff line change
Expand Up @@ -184,12 +184,8 @@ def main(
sources.append(Path("-"))
else:
err(f"invalid path: {s}")
if check and diff:
exc = click.ClickException("Options --check and --diff are mutually exclusive")
exc.exit_code = 2
raise exc

if check:
if check and not diff:
write_back = WriteBack.NO
elif diff:
write_back = WriteBack.DIFF
Expand Down
9 changes: 9 additions & 0 deletions tests/test_black.py
Original file line number Diff line number Diff line change
Expand Up @@ -595,6 +595,15 @@ def test_write_cache_write_fail(self) -> None:
mock.side_effect = OSError
black.write_cache({}, [])

def test_check_diff_use_together(self) -> None:
with cache_dir() as workspace:
src = (workspace / "test.py").resolve()
with src.open("w") as fobj:
fobj.write("print('hello_bad_indented')")
result = CliRunner().invoke(black.main, [str(src), "--diff", "--check"])
self.assertEqual(result.exit_code, 0)
self.assertFalse(black.CACHE_FILE.exists())


if __name__ == "__main__":
unittest.main()

0 comments on commit 3f72197

Please sign in to comment.