@@ -17,17 +17,32 @@ def test_version(tmpdir, capsys):
1717
1818
1919class 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 ):
2221 with (fixture_dir / ".relint.yml" ).open () as fs :
2322 config = fs .read ()
2423 tmpdir .join (".relint.yml" ).write (config )
24+ tmpdir .join ("dummy.py" ).write ("# TODO do something" )
2525 with tmpdir .as_cwd ():
2626 with pytest .raises (SystemExit ) as exc_info :
27- main (["relint.py" , filename ])
27+ main (["relint.py" , "dummy.py" ])
2828
2929 assert exc_info .value .code == 0
3030
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+
3146 def test_main_execution_with_custom_template (self , capsys , tmpdir , fixture_dir ):
3247 with (fixture_dir / ".relint.yml" ).open () as fs :
3348 config = fs .read ()
@@ -45,16 +60,16 @@ def test_main_execution_with_custom_template(self, capsys, tmpdir, fixture_dir):
4560 assert expected_message == out
4661 assert exc_info .value .code == 0
4762
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 ):
5064 with (fixture_dir / ".relint.yml" ).open () as fs :
5165 config = fs .read ()
5266 tmpdir .join (".relint.yml" ).write (config )
67+ tmpdir .join ("dummy.py" ).write ("# TODO do something" )
5368 with tmpdir .as_cwd ():
5469 with pytest .raises (SystemExit ) as exc_info :
55- main (["relint.py" , "-W " , filename ])
70+ main (["relint.py" , "dummy.py " , "-W" ])
5671
57- assert exc_info .value .code != 0
72+ assert exc_info .value .code == 1
5873
5974 def test_main_execution_with_diff (self , capsys , mocker , tmpdir , fixture_dir ):
6075 with (fixture_dir / ".relint.yml" ).open () as fs :
0 commit comments