66# Define the directory containing the test JSON files
77VALID_DATACITE43_DIR = "../tests/data/datacite43/" # Directory for valid JSON files
88
9+
910# Function to get all JSON files in the directory
1011def get_all_json_files (directory ):
11- return [os .path .join (directory , f ) for f in os .listdir (directory ) if f .endswith ('.json' )]
12+ return [
13+ os .path .join (directory , f ) for f in os .listdir (directory ) if f .endswith (".json" )
14+ ]
15+
1216
1317# Get list of all valid JSON files in the directory
1418VALID_DATACITE43_FILES = get_all_json_files (VALID_DATACITE43_DIR )
1519
20+
1621@pytest .mark .parametrize ("valid_file" , VALID_DATACITE43_FILES )
1722def test_valid_json (valid_file ):
1823 """Test that valid example files validate successfully."""
@@ -23,24 +28,25 @@ def test_valid_json(valid_file):
2328 validation_errors = validator43 (json_data )
2429 except ValueError as e :
2530 pytest .fail (f"Validation failed for: { valid_file } \n Errors: { str (e )} " )
26-
31+
2732 if validation_errors :
2833 pytest .fail (f"Validation failed for: { valid_file } \n Errors: { validation_errors } " )
2934 else :
3035 print (f"Validation passed for: { valid_file } " )
3136
37+
3238if __name__ == "__main__" :
3339 # Track failures for manual testing
3440 failed_files = []
35-
41+
3642 # Run the tests and print results for each file
3743 for file in VALID_DATACITE43_FILES :
3844 try :
3945 test_valid_json (file )
4046 except AssertionError as e :
4147 failed_files .append (file )
4248 print (f"Error occurred in file: { file } \n Error details: { e } " )
43-
49+
4450 # Print a summary of all failed files
4551 if failed_files :
4652 print ("\n The following files failed validation:" )
0 commit comments