Skip to content

Commit

Permalink
Use assert_messages!()
Browse files Browse the repository at this point in the history
  • Loading branch information
evanrittenhouse committed Apr 11, 2023
1 parent 5add380 commit 796c32e
Show file tree
Hide file tree
Showing 6 changed files with 69 additions and 120 deletions.
5 changes: 2 additions & 3 deletions crates/ruff/src/rules/flake8_todo/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,11 @@ mod tests {
use std::path::Path;

use anyhow::Result;
use insta::assert_yaml_snapshot;
use test_case::test_case;

use crate::registry::Rule;
use crate::settings;
use crate::test::test_path;
use crate::{assert_messages, settings};

#[test_case(Rule::InvalidTodoTag, Path::new("TDO001.py"); "TDO001")]
#[test_case(Rule::MissingAuthorInTodo, Path::new("TDO002.py"); "TDO002")]
Expand All @@ -24,7 +23,7 @@ mod tests {
Path::new("flake8_todo").join(path).as_path(),
&settings::Settings::for_rule(rule_code),
)?;
assert_yaml_snapshot!(snapshot, diagnostics);
assert_messages!(snapshot, diagnostics);
Ok(())
}
}
Original file line number Diff line number Diff line change
@@ -1,47 +1,30 @@
---
source: crates/ruff/src/rules/flake8_todo/mod.rs
expression: diagnostics
---
- kind:
name: InvalidTodoTag
body: "Invalid TODO tag: `XXX` should be `TODO`"
suggestion: ~
fixable: false
location:
row: 7
column: 0
end_location:
row: 7
column: 40
fix:
edits: []
parent: ~
- kind:
name: InvalidTodoTag
body: "Invalid TODO tag: `BUG` should be `TODO`"
suggestion: ~
fixable: false
location:
row: 8
column: 0
end_location:
row: 8
column: 40
fix:
edits: []
parent: ~
- kind:
name: InvalidTodoTag
body: "Invalid TODO tag: `FIXME` should be `TODO`"
suggestion: ~
fixable: false
location:
row: 9
column: 0
end_location:
row: 9
column: 42
fix:
edits: []
parent: ~
TDO001.py:7:1: TDO001 Invalid TODO tag: `XXX` should be `TODO`
|
7 | # T001 - errors
8 | # XXX(evanrittenhouse): this is not fine
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ TDO001
9 | # BUG(evanrittenhouse): this is not fine
10 | # FIXME(evanrittenhouse): this is not fine
|

TDO001.py:8:1: TDO001 Invalid TODO tag: `BUG` should be `TODO`
|
8 | # T001 - errors
9 | # XXX(evanrittenhouse): this is not fine
10 | # BUG(evanrittenhouse): this is not fine
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ TDO001
11 | # FIXME(evanrittenhouse): this is not fine
|

TDO001.py:9:1: TDO001 Invalid TODO tag: `FIXME` should be `TODO`
|
9 | # XXX(evanrittenhouse): this is not fine
10 | # BUG(evanrittenhouse): this is not fine
11 | # FIXME(evanrittenhouse): this is not fine
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ TDO001
|


Original file line number Diff line number Diff line change
@@ -1,19 +1,12 @@
---
source: crates/ruff/src/rules/flake8_todo/mod.rs
expression: diagnostics
---
- kind:
name: MissingAuthorInTodo
body: Missing author into TODO
suggestion: ~
fixable: false
location:
row: 4
column: 0
end_location:
row: 4
column: 26
fix:
edits: []
parent: ~
TDO002.py:4:1: TDO002 Missing author into TODO
|
4 | # TODO(evanrittenhouse): this has an author
5 | # T002 - errors
6 | # TODO: this has no author
| ^^^^^^^^^^^^^^^^^^^^^^^^^^ TDO002
|


Original file line number Diff line number Diff line change
@@ -1,19 +1,12 @@
---
source: crates/ruff/src/rules/flake8_todo/mod.rs
expression: diagnostics
---
- kind:
name: MissingColonInTodo
body: Missing colon in TODO
suggestion: ~
fixable: false
location:
row: 4
column: 0
end_location:
row: 4
column: 41
fix:
edits: []
parent: ~
TDO004.py:4:1: TDO004 Missing colon in TODO
|
4 | # TODO(evanrittenhouse): this has a colon
5 | # T004 - errors
6 | # TODO(evanrittenhouse) this has no colon
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ TDO004
|


Original file line number Diff line number Diff line change
@@ -1,19 +1,12 @@
---
source: crates/ruff/src/rules/flake8_todo/mod.rs
expression: diagnostics
---
- kind:
name: MissingSpaceAfterColonInTodo
body: Missing space after colon in TODO
suggestion: ~
fixable: false
location:
row: 4
column: 0
end_location:
row: 4
column: 55
fix:
edits: []
parent: ~
TDO007.py:4:1: TDO007 Missing space after colon in TODO
|
4 | # TODO(evanrittenhouse): this has a space after a colon
5 | # T007 - errors
6 | # TODO(evanrittenhouse):this has no space after a colon
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ TDO007
|


Original file line number Diff line number Diff line change
@@ -1,33 +1,21 @@
---
source: crates/ruff/src/rules/flake8_todo/mod.rs
expression: diagnostics
---
- kind:
name: MissingTextInTodo
body: Missing text in TODO
suggestion: ~
fixable: false
location:
row: 4
column: 0
end_location:
row: 4
column: 24
fix:
edits: []
parent: ~
- kind:
name: MissingTextInTodo
body: Missing text in TODO
suggestion: ~
fixable: false
location:
row: 5
column: 0
end_location:
row: 5
column: 23
fix:
edits: []
parent: ~
TDO005.py:4:1: TDO005 Missing text in TODO
|
4 | # TODO(evanrittenhouse): this has text, while the errors do not
5 | # T005 - errors
6 | # TODO(evanrittenhouse):
| ^^^^^^^^^^^^^^^^^^^^^^^^ TDO005
7 | # TODO(evanrittenhouse)
|

TDO005.py:5:1: TDO005 Missing text in TODO
|
5 | # T005 - errors
6 | # TODO(evanrittenhouse):
7 | # TODO(evanrittenhouse)
| ^^^^^^^^^^^^^^^^^^^^^^^ TDO005
|


0 comments on commit 796c32e

Please sign in to comment.