File tree Expand file tree Collapse file tree 3 files changed +27
-5
lines changed Expand file tree Collapse file tree 3 files changed +27
-5
lines changed Original file line number Diff line number Diff line change 1919)
2020
2121
22- def main ():
22+ def main (argv : list [ str ] = None ):
2323 """Run the checker on the files passed on the command line."""
24- args = PARSER .parse_args ()
24+ args = PARSER .parse_args (argv )
2525
2626 files = args .files
2727 if len (files ) == 1 and os .path .isdir (files [0 ]):
2828 files = find_c_cpp_files (files [0 ])
2929
3030 # See which of the headers include Python.h and add them to the list
3131 n_out_of_order = process_files (files )
32- sys . exit ( n_out_of_order )
32+ return n_out_of_order
3333
3434
3535if __name__ == "__main__" :
36- main ()
36+ sys . exit ( main () )
Original file line number Diff line number Diff line change 1+ """Test the function used by the installed script."""
2+
3+ import os .path
4+
5+ import pytest
6+
7+ from check_python_h_first .__main__ import main
8+
9+ THIS_DIR = os .path .dirname (__file__ )
10+
11+
12+ @pytest .mark .parametrize ("to_pass" , [None , []])
13+ def test_call_empty (to_pass ):
14+ """Test that calling without arguments fails."""
15+ with pytest .raises (SystemExit ):
16+ assert main (to_pass ) != 0
17+
18+
19+ def test_call_single ():
20+ """Test that calling with a single directory finds files."""
21+ assert main ([THIS_DIR ]) > 0
Original file line number Diff line number Diff line change @@ -42,7 +42,8 @@ def test_process_files():
4242 """
4343 result = process_files (HEADER_LIST + SOURCE_LIST )
4444 assert result == sum (
45- os .path .basename (name ).startswith ("system" ) or os .path .basename (name ).startswith ("bad" )
45+ os .path .basename (name ).startswith ("system" )
46+ or os .path .basename (name ).startswith ("bad" )
4647 for name in HEADER_LIST + SOURCE_LIST
4748 )
4849
You can’t perform that action at this time.
0 commit comments