7 def test_good(lint
, config
, paths
):
8 results
= lint(paths("subdir/good.rs"))
10 assert len(results
) == 0
13 def test_basic(lint
, config
, paths
):
14 results
= lint(paths("subdir/bad.rs"))
16 assert len(results
) >= 1
18 assert "Reformat rust" in results
[0].message
19 assert results
[0].level
== "warning"
20 assert results
[0].lineno
== 4
21 assert "bad.rs" in results
[0].path
22 assert "Print text to the console" in results
[0].diff
25 def test_dir(lint
, config
, paths
):
26 results
= lint(paths("subdir/"))
28 assert len(results
) >= 4
30 assert "Reformat rust" in results
[0].message
31 assert results
[0].level
== "warning"
32 assert results
[0].lineno
== 4
33 assert "bad.rs" in results
[0].path
34 assert "Print text to the console" in results
[0].diff
36 assert "Reformat rust" in results
[1].message
37 assert results
[1].level
== "warning"
38 assert results
[1].lineno
== 4
39 assert "bad2.rs" in results
[1].path
40 assert "Print text to the console" in results
[1].diff
43 def test_fix(lint
, create_temp_file
):
44 contents
= """fn main() {
45 // Statements here are executed when the compiled binary is called
47 // Print text to the console
48 println!("Hello World!");
51 let mut vec = Vec::new();
63 path
= create_temp_file(contents
, "bad.rs")
64 lint([path
], fix
=True)
68 if __name__
== "__main__":