diff --git a/test/unit_tests/test_metadata_table.py b/test/unit_tests/test_metadata_table.py old mode 100644 new mode 100755 index ce314e8b..d9791879 --- a/test/unit_tests/test_metadata_table.py +++ b/test/unit_tests/test_metadata_table.py @@ -85,8 +85,7 @@ def test_bad_type_name(self): #Exercise with self.assertRaises(Exception) as context: - tables = parse_metadata_file(filename, known_ddts, - self._DUMMY_RUN_ENV) + _ = parse_metadata_file(filename, known_ddts, self._DUMMY_RUN_ENV) #Verify #print("The exception is", context.exception) @@ -98,8 +97,7 @@ def test_double_header(self): filename = os.path.join(SAMPLE_FILES_DIR, "double_header.meta") with self.assertRaises(Exception) as context: - tables = parse_metadata_file(filename, known_ddts, - self._DUMMY_RUN_ENV) + _ = parse_metadata_file(filename, known_ddts, self._DUMMY_RUN_ENV) #print("The exception is", context.exception) self.assertTrue('table already contains \'test_host\'' in str(context.exception)) @@ -110,8 +108,7 @@ def test_bad_dimension(self): filename = os.path.join(SAMPLE_FILES_DIR, "test_bad_dimension.meta") with self.assertRaises(Exception) as context: - tables = parse_metadata_file(filename, known_ddts, - self._DUMMY_RUN_ENV) + _ = parse_metadata_file(filename, known_ddts, self._DUMMY_RUN_ENV) #print("The exception is", context.exception) self.assertTrue('Invalid \'dimensions\' property value, \'' in str(context.exception)) @@ -123,8 +120,7 @@ def test_duplicate_variable(self): "test_duplicate_variable.meta") with self.assertRaises(Exception) as context: - tables = parse_metadata_file(filename, known_ddts, - self._DUMMY_RUN_ENV) + _ = parse_metadata_file(filename, known_ddts, self._DUMMY_RUN_ENV) #print("The exception is", context.exception) self.assertTrue('Invalid (duplicate) standard name in temp_calc_adjust_run, defined at ' in str(context.exception)) @@ -135,8 +131,7 @@ def test_invalid_intent(self): filename = os.path.join(SAMPLE_FILES_DIR, "test_invalid_intent.meta") with self.assertRaises(Exception) as context: - tables = parse_metadata_file(filename, known_ddts, - self._DUMMY_RUN_ENV) + _ = parse_metadata_file(filename, known_ddts, self._DUMMY_RUN_ENV) #print("The exception is", context.exception) self.assertTrue('Invalid \'intent\' property value, \'banana\', at ' in str(context.exception)) @@ -147,8 +142,7 @@ def test_missing_intent(self): filename = os.path.join(SAMPLE_FILES_DIR, "test_missing_intent.meta") with self.assertRaises(Exception) as context: - tables = parse_metadata_file(filename, known_ddts, - self._DUMMY_RUN_ENV) + _ = parse_metadata_file(filename, known_ddts, self._DUMMY_RUN_ENV) #print("The exception is", context.exception) emsg = "Required property, 'intent', missing, at " @@ -160,8 +154,7 @@ def test_missing_units(self): filename = os.path.join(SAMPLE_FILES_DIR, "test_missing_units.meta") with self.assertRaises(Exception) as context: - tables = parse_metadata_file(filename, known_ddts, - self._DUMMY_RUN_ENV) + _ = parse_metadata_file(filename, known_ddts, self._DUMMY_RUN_ENV) #print("The exception is", context.exception) emsg = "Required property, 'units', missing, at" @@ -174,8 +167,7 @@ def test_missing_table_type(self): "test_missing_table_type.meta") with self.assertRaises(Exception) as context: - tables = parse_metadata_file(filename, known_ddts, - self._DUMMY_RUN_ENV) + _ = parse_metadata_file(filename, known_ddts, self._DUMMY_RUN_ENV) #print("The exception is", context.exception) emsg = "Invalid section type, 'None'" @@ -187,8 +179,7 @@ def test_bad_table_type(self): filename = os.path.join(SAMPLE_FILES_DIR, "test_bad_table_type.meta") with self.assertRaises(Exception) as context: - tables = parse_metadata_file(filename, known_ddts, - self._DUMMY_RUN_ENV) + _ = parse_metadata_file(filename, known_ddts, self._DUMMY_RUN_ENV) #print("The exception is", context.exception) emsg = "Section type, 'host', does not match table type, 'scheme'" @@ -201,8 +192,7 @@ def test_missing_table_name(self): "test_missing_table_name.meta") with self.assertRaises(Exception) as context: - tables = parse_metadata_file(filename, known_ddts, - self._DUMMY_RUN_ENV) + _ = parse_metadata_file(filename, known_ddts, self._DUMMY_RUN_ENV) #print("The exception is", context.exception) emsg = "Section name, 'None', does not match table title, 'test_missing_table_name'" @@ -214,8 +204,7 @@ def test_bad_table_key(self): filename = os.path.join(SAMPLE_FILES_DIR, "test_bad_table_key.meta") with self.assertRaises(Exception) as context: - tables = parse_metadata_file(filename, known_ddts, - self._DUMMY_RUN_ENV) + _ = parse_metadata_file(filename, known_ddts, self._DUMMY_RUN_ENV) #print("The exception is", context.exception) emsg = "Invalid metadata table start property, 'something', at " @@ -227,8 +216,7 @@ def test_bad_line_split(self): filename = os.path.join(SAMPLE_FILES_DIR, "test_bad_line_split.meta") with self.assertRaises(Exception) as context: - tables = parse_metadata_file(filename, known_ddts, - self._DUMMY_RUN_ENV) + _ = parse_metadata_file(filename, known_ddts, self._DUMMY_RUN_ENV) #print("The exception is", context.exception) emsg = "Invalid variable property syntax, \'\', at " @@ -240,8 +228,7 @@ def test_unknown_ddt_type(self): filename = os.path.join(SAMPLE_FILES_DIR, "test_unknown_ddt_type.meta") with self.assertRaises(Exception) as context: - tables = parse_metadata_file(filename, known_ddts, - self._DUMMY_RUN_ENV) + _ = parse_metadata_file(filename, known_ddts, self._DUMMY_RUN_ENV) #print("The exception is", context.exception) emsg = "Unknown DDT type, banana, at " @@ -253,8 +240,7 @@ def test_bad_var_property_name(self): filename = os.path.join(SAMPLE_FILES_DIR, "test_bad_var_property_name.meta") with self.assertRaises(Exception) as context: - tables = parse_metadata_file(filename, known_ddts, - self._DUMMY_RUN_ENV) + _ = parse_metadata_file(filename, known_ddts, self._DUMMY_RUN_ENV) #print("The exception is", context.exception) emsg = "Invalid variable property name, 'none', at " @@ -312,8 +298,7 @@ def test_bad_1st_ccpp_arg_table(self): "test_bad_1st_arg_table_header.meta") with self.assertRaises(Exception) as context: - tables = parse_metadata_file(filename, known_ddts, - self._DUMMY_RUN_ENV) + _ = parse_metadata_file(filename, known_ddts, self._DUMMY_RUN_ENV) #print("The exception is", context.exception) emsg = "Invalid variable property syntax, '[ccpp-farg-table]', at " @@ -326,8 +311,7 @@ def test_bad_2nd_ccpp_arg_table(self): "test_bad_2nd_arg_table_header.meta") with self.assertRaises(Exception) as context: - tables = parse_metadata_file(filename, known_ddts, - self._DUMMY_RUN_ENV) + _ = parse_metadata_file(filename, known_ddts, self._DUMMY_RUN_ENV) #print("The exception is", context.exception) emsg = "Invalid variable property syntax, '[ccpp-farg-table]', at " @@ -341,8 +325,7 @@ def test_mismatch_section_table_title(self): "test_mismatch_section_table_title.meta") with self.assertRaises(Exception) as context: - tables = parse_metadata_file(filename, known_ddts, - self._DUMMY_RUN_ENV) + _ = parse_metadata_file(filename, known_ddts, self._DUMMY_RUN_ENV) #print("The exception is", context.exception) emsg = "Section name, 'test_host', does not match table title, 'banana', at " @@ -355,8 +338,7 @@ def test_double_table_properties(self): "double_table_properties.meta") with self.assertRaises(Exception) as context: - tables = parse_metadata_file(filename, known_ddts, - self._DUMMY_RUN_ENV) + _ = parse_metadata_file(filename, known_ddts, self._DUMMY_RUN_ENV) #print("The exception is", context.exception) emsg = "Duplicate metadata table, test_host, at " @@ -369,8 +351,7 @@ def test_missing_table_properties(self): "missing_table_properties.meta") with self.assertRaises(Exception) as context: - tables = parse_metadata_file(filename, known_ddts, - self._DUMMY_RUN_ENV) + _ = parse_metadata_file(filename, known_ddts, self._DUMMY_RUN_ENV) #print("The exception is", context.exception) emsg = "Invalid CCPP metadata line, '[ccpp-arg-table]', at " @@ -407,8 +388,7 @@ def test_invalid_table_properties_type(self): "test_invalid_table_properties_type.meta") with self.assertRaises(Exception) as context: - tables = parse_metadata_file(filename, known_ddts, - self._DUMMY_RUN_ENV) + _ = parse_metadata_file(filename, known_ddts, self._DUMMY_RUN_ENV) #print("The exception is", context.exception) emsg = "Invalid metadata table type, 'banana', at " diff --git a/tests/test_metadata_parser.py b/tests/test_metadata_parser.py index 5ce55dab..0f7d18d6 100644 --- a/tests/test_metadata_parser.py +++ b/tests/test_metadata_parser.py @@ -2,10 +2,9 @@ import os import sys -#sys.path.append(os.path.join(os.path.split(__file__)[0], '../scripts/parse_tools')) from parse_checkers import registered_fortran_ddt_names from metadata_table import MetadataTable, parse_metadata_file, Var -#from metadata_table import MetadataHeader +from framework_env import CCPPFrameworkEnv example_table = """ [ccpp-table-properties] @@ -32,8 +31,13 @@ def test_MetadataTable_parse_table(tmpdir): with open(path, "w") as f: f.write(example_table) + dummy_run_env = CCPPFrameworkEnv(None, ndict={'host_files':'', + 'scheme_files':'', + 'suites':''}) + + metadata_headers = parse_metadata_file(path, known_ddts=registered_fortran_ddt_names(), - logger=logging.getLogger(__name__)) + run_env=dummy_run_env) # check metadata header assert len(metadata_headers) == 1