@@ -26,6 +26,13 @@ def test_format(tmp_path):
2626 assert file_path .read_text () == FORMATTED_MARKDOWN
2727
2828
29+ def test_format__exit_non_zero (tmp_path ):
30+ file_path = tmp_path / "test_markdown.md"
31+ file_path .write_text (UNFORMATTED_MARKDOWN )
32+ assert run ((str (file_path ),), "--exit-non-zero-on-format" ) == 1
33+ assert file_path .read_text () == FORMATTED_MARKDOWN
34+
35+
2936def test_format__folder (tmp_path ):
3037 file_path_1 = tmp_path / "test_markdown1.md"
3138 file_path_2 = tmp_path / "test_markdown2.md"
@@ -39,6 +46,19 @@ def test_format__folder(tmp_path):
3946 assert file_path_3 .read_text () == UNFORMATTED_MARKDOWN
4047
4148
49+ def test_format__folder_exit_non_zero (tmp_path ):
50+ file_path_1 = tmp_path / "test_markdown1.md"
51+ file_path_2 = tmp_path / "test_markdown2.md"
52+ file_path_3 = tmp_path / "not_markdown3"
53+ file_path_1 .write_text (UNFORMATTED_MARKDOWN )
54+ file_path_2 .write_text (UNFORMATTED_MARKDOWN )
55+ file_path_3 .write_text (UNFORMATTED_MARKDOWN )
56+ assert run ((str (tmp_path ),), "--exit-non-zero-on-format" ) == 1
57+ assert file_path_1 .read_text () == FORMATTED_MARKDOWN
58+ assert file_path_2 .read_text () == FORMATTED_MARKDOWN
59+ assert file_path_3 .read_text () == UNFORMATTED_MARKDOWN
60+
61+
4262def test_format__folder_leads_to_invalid (tmp_path ):
4363 file_path_1 = tmp_path / "test_markdown1.md"
4464 file_path_1 .mkdir ()
0 commit comments