Skip to content

Commit 353ca5a

Browse files
authored
Don't save unmodified file to the disk (#273)
* Don't save unmodified file to the disk * Other -> Fixes * Update tests with not_modified options - robotidy should not write file to disk
1 parent d28f9ef commit 353ca5a

File tree

31 files changed

+65
-683
lines changed

31 files changed

+65
-683
lines changed

CHANGES.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,9 @@
4141
robotidy --check --overwrite src
4242
```
4343

44+
### Fixes
45+
- Unmodified files are now not saved to the disk ([#237](https://github.com/MarketSquare/robotframework-tidy/issues/237))
46+
4447
## 1.6.2
4548

4649
### Fixes

robotidy/app.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ def transform_files(self):
6767
self.output_diff(model.source, old_model, new_model)
6868
if stdin:
6969
self.print_to_stdout(new_model)
70-
else:
70+
elif diff:
7171
self.save_model(model.source, model)
7272
except DataError:
7373
click.echo(

tests/atest/transformers/AlignTestCases/expected/empty_line.robot

Lines changed: 0 additions & 12 deletions
This file was deleted.

tests/atest/transformers/AlignTestCases/expected/for_loops.robot

Lines changed: 0 additions & 22 deletions
This file was deleted.

tests/atest/transformers/AlignTestCases/expected/no_header_col_only_headers.robot

Lines changed: 0 additions & 13 deletions
This file was deleted.

tests/atest/transformers/AlignTestCases/test_transformer.py

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,21 +11,23 @@ class TestAlignTestCases(TransformerAcceptanceTest):
1111
[
1212
"test.robot",
1313
"no_header_col.robot",
14-
"for_loops.robot",
1514
"with_settings.robot",
1615
"templated_for_loops.robot",
1716
"templated_for_loops_and_without.robot",
1817
"templated_for_loops_header_cols.robot",
19-
"empty_line.robot",
2018
],
2119
)
2220
def test_transformer(self, source):
2321
self.compare(source=source, expected=source)
2422

23+
@pytest.mark.parametrize("source", ["for_loops.robot", "empty_line.robot"])
24+
def test_should_not_modify(self, source):
25+
self.compare(source=source, not_modified=True)
26+
2527
def test_only_with_headers(self):
2628
self.compare(
2729
source="no_header_col.robot",
28-
expected="no_header_col_only_headers.robot",
30+
not_modified=True,
2931
config=":only_with_headers=True",
3032
)
3133

tests/atest/transformers/InlineIf/expected/invalid_if.robot

Lines changed: 0 additions & 133 deletions
This file was deleted.

tests/atest/transformers/InlineIf/expected/invalid_inline_if.robot

Lines changed: 0 additions & 160 deletions
This file was deleted.

0 commit comments

Comments
 (0)