@@ -17,17 +17,32 @@ def test_version(tmpdir, capsys):
17
17
18
18
19
19
class TestMain :
20
- @pytest .mark .parametrize ("filename" , ["test_parse.py" , "[a-b].py" , "[b-a].py" ])
21
- def test_main_execution (self , filename , tmpdir , fixture_dir ):
20
+ def test_main_execution (self , tmpdir , fixture_dir ):
22
21
with (fixture_dir / ".relint.yml" ).open () as fs :
23
22
config = fs .read ()
24
23
tmpdir .join (".relint.yml" ).write (config )
24
+ tmpdir .join ("dummy.py" ).write ("# TODO do something" )
25
25
with tmpdir .as_cwd ():
26
26
with pytest .raises (SystemExit ) as exc_info :
27
- main (["relint.py" , filename ])
27
+ main (["relint.py" , "dummy.py" ])
28
28
29
29
assert exc_info .value .code == 0
30
30
31
+ def test_main_execution_with_error (self , capsys , tmpdir , fixture_dir ):
32
+ with (fixture_dir / ".relint.yml" ).open () as fs :
33
+ config = fs .read ()
34
+ tmpdir .join (".relint.yml" ).write (config )
35
+ tmpdir .join ("dummy.py" ).write ("# FIXME do something" )
36
+ with tmpdir .as_cwd ():
37
+ with pytest .raises (SystemExit ) as exc_info :
38
+ main (["relint.py" , "dummy.py" ])
39
+
40
+ expected_message = "dummy.py:1 No fixme (warning)\n Hint: Fix it right away!\n 1> # FIXME do something\n "
41
+
42
+ out , _ = capsys .readouterr ()
43
+ assert expected_message == out
44
+ assert exc_info .value .code == 1
45
+
31
46
def test_main_execution_with_custom_template (self , capsys , tmpdir , fixture_dir ):
32
47
with (fixture_dir / ".relint.yml" ).open () as fs :
33
48
config = fs .read ()
@@ -45,16 +60,16 @@ def test_main_execution_with_custom_template(self, capsys, tmpdir, fixture_dir):
45
60
assert expected_message == out
46
61
assert exc_info .value .code == 0
47
62
48
- @pytest .mark .parametrize ("filename" , ["test_parse.py" , "[a-b].py" , "[b-a].py" ])
49
- def test_raise_for_warnings (self , filename , tmpdir , fixture_dir ):
63
+ def test_raise_for_warnings (self , tmpdir , fixture_dir ):
50
64
with (fixture_dir / ".relint.yml" ).open () as fs :
51
65
config = fs .read ()
52
66
tmpdir .join (".relint.yml" ).write (config )
67
+ tmpdir .join ("dummy.py" ).write ("# TODO do something" )
53
68
with tmpdir .as_cwd ():
54
69
with pytest .raises (SystemExit ) as exc_info :
55
- main (["relint.py" , "-W " , filename ])
70
+ main (["relint.py" , "dummy.py " , "-W" ])
56
71
57
- assert exc_info .value .code != 0
72
+ assert exc_info .value .code == 1
58
73
59
74
def test_main_execution_with_diff (self , capsys , mocker , tmpdir , fixture_dir ):
60
75
with (fixture_dir / ".relint.yml" ).open () as fs :
0 commit comments