File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -168,6 +168,29 @@ def test_basic(
168168 (tmp_path / "empty" ).mkdir ()
169169 assert cs .main (tmp_path ) == 0
170170
171+ def test_write_changes_lists_changes (
172+ tmp_path : Path ,
173+ capsys : pytest .CaptureFixture [str ],
174+ ) -> None :
175+ """Test that -w flag shows list of changes made to file."""
176+
177+ fname = tmp_path / "misspelled.txt"
178+ fname .write_text ("This is abandonned\n And this is occured\n Also teh typo\n " )
179+
180+ result = cs .main ("-w" , fname , std = True )
181+ assert isinstance (result , tuple )
182+ code , _ , stderr = result
183+ assert code == 0
184+
185+ assert "FIXED:" in stderr
186+
187+ # Check that changes are listed with format: filename:line: wrong ==> right
188+ assert "misspelled.txt:1: abandonned ==> abandoned" in stderr
189+ assert "misspelled.txt:2: occured ==> occurred" in stderr
190+ assert "misspelled.txt:3: teh ==> the" in stderr
191+
192+ corrected = fname .read_text ()
193+ assert corrected == "This is abandoned\n And this is occurred\n Also the typo\n "
171194
172195def test_default_word_parsing (
173196 tmp_path : Path ,
You can’t perform that action at this time.
0 commit comments