1616
1717_HERE = pathlib .Path (__file__ ).resolve ().parent
1818
19+ INPUT_PATH = _HERE .joinpath ('examples' , 'empty.f' )
20+
1921INPUT_PATHS = list (pathlib .Path (_HERE , 'examples' ).glob ('**/*.*' ))
2022INPUT_PATHS_LARGE = list (pathlib .Path (_HERE , 'examples_large' ).glob ('**/*.*' ))
2123VERBOSITIES = (0 , 20 , 80 , 100 )
2224
25+ SOME_INPUT_PATHS = [_HERE .joinpath ('examples' , _ ) for _ in ('comments.f' , 'strings.f90' )]
26+ SOME_INPUT_PATHS_LARGE = [_HERE .joinpath ('examples_large' , 'ORCHIDEE_grid.f90' )]
27+ SOME_VERBOSITIES = (0 , 100 )
28+
2329
2430class Tests (unittest .TestCase ):
2531
@@ -30,7 +36,6 @@ def test_config_variants(self):
3036 options = java_config ['options' ]
3137 ofp_class = java_config ['ofp_class' ]
3238 ofp_xml_class = java_config ['ofp_xml_class' ]
33- input_path = pathlib .Path ('test' , 'examples' , 'empty.f' )
3439 for classpath , verbosity , invalid_options in itertools .product (
3540 (None , java_config ['classpath' ]), (0 , 100 , 'invalid' ),
3641 ([], ['--invalid' , 'option' ], ['--help' , 'true' ])):
@@ -50,7 +55,7 @@ def test_config_variants(self):
5055 if output_path is not None :
5156 command += ['--output' , str (output_path )]
5257 command += invalid_options
53- command .append (str (input_path ))
58+ command .append (str (INPUT_PATH ))
5459
5560 if invalid_options or verbosity == 'invalid' \
5661 or classpath is None and 'CLASSPATH' not in os .environ :
@@ -64,17 +69,16 @@ def test_unset_config(self):
6469 classpath = java_config ['classpath' ]
6570 options = java_config ['options' ]
6671
67- input_path = pathlib .Path ('test' , 'examples' , 'empty.f' )
6872 java_config ['classpath' ] = None
6973 with tempfile .NamedTemporaryFile () as output_file :
70- execute_parser (input_path , pathlib .Path (output_file .name ))
74+ execute_parser (INPUT_PATH , pathlib .Path (output_file .name ))
7175
7276 java_config ['classpath' ] = classpath
7377 java_config ['options' ] = options
7478
7579 def test_execute_parser_stdout (self ):
76- for input_path in INPUT_PATHS :
77- for verbosity in VERBOSITIES :
80+ for input_path in SOME_INPUT_PATHS :
81+ for verbosity in SOME_VERBOSITIES :
7882 with self .subTest (input_path = input_path , verbosity = verbosity ):
7983 process = execute_parser (input_path , None , verbosity )
8084 self .assertEqual (process .returncode , 0 )
@@ -87,7 +91,8 @@ def test_generate_xml(self):
8791 for input_path in INPUT_PATHS :
8892 for verbosity in VERBOSITIES :
8993 with self .subTest (input_path = input_path , verbosity = verbosity ):
90- output_path = pathlib .Path (results_path , input_path .name + '.xml' )
94+ output_path = results_path .joinpath (
95+ '{}.{}.xml' .format (input_path .name , verbosity ))
9196 process = execute_parser (input_path , output_path , verbosity )
9297 self .assertEqual (process .returncode , 0 , process )
9398 self .assertTrue (output_path .exists ())
@@ -99,7 +104,8 @@ def test_generate_xml_large(self):
99104 for input_path in INPUT_PATHS_LARGE :
100105 for verbosity in VERBOSITIES :
101106 with self .subTest (input_path = input_path , verbosity = verbosity ):
102- output_path = pathlib .Path (results_path , input_path .name + '.xml' )
107+ output_path = results_path .joinpath (
108+ '{}.{}.xml' .format (input_path .name , verbosity ))
103109 process = execute_parser (input_path , output_path , verbosity )
104110 self .assertEqual (process .returncode , 0 )
105111 self .assertTrue (output_path .exists ())
@@ -114,16 +120,16 @@ def _validate_tree(self, tree):
114120 self .assertGreater (len (file_node ), 0 )
115121
116122 def test_parse (self ):
117- for input_path in INPUT_PATHS :
118- for verbosity in VERBOSITIES :
123+ for input_path in SOME_INPUT_PATHS :
124+ for verbosity in SOME_VERBOSITIES :
119125 with self .subTest (input_path = input_path , verbosity = verbosity ):
120126 root_node = parse (input_path , verbosity )
121127 self ._validate_tree (root_node )
122128
123129 @unittest .skipUnless (os .environ .get ('TEST_LONG' ), 'skipping long test' )
124130 def test_parse_large (self ):
125- for input_path in INPUT_PATHS_LARGE :
126- for verbosity in VERBOSITIES :
131+ for input_path in SOME_INPUT_PATHS_LARGE :
132+ for verbosity in SOME_VERBOSITIES :
127133 with self .subTest (input_path = input_path , verbosity = verbosity ):
128134 root_node = parse (input_path , verbosity )
129135 self ._validate_tree (root_node )
0 commit comments