Skip to content

Commit 7c8a434

Browse files
Update tester.py
1 parent d1230dc commit 7c8a434

File tree

1 file changed

+10
-4
lines changed

1 file changed

+10
-4
lines changed

tests/tester.py

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,13 +6,18 @@
66
# Define the directory containing the test JSON files
77
VALID_DATACITE43_DIR = "../tests/data/datacite43/" # Directory for valid JSON files
88

9+
910
# Function to get all JSON files in the directory
1011
def 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
1418
VALID_DATACITE43_FILES = get_all_json_files(VALID_DATACITE43_DIR)
1519

20+
1621
@pytest.mark.parametrize("valid_file", VALID_DATACITE43_FILES)
1722
def 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}\nErrors: {str(e)}")
26-
31+
2732
if validation_errors:
2833
pytest.fail(f"Validation failed for: {valid_file}\nErrors: {validation_errors}")
2934
else:
3035
print(f"Validation passed for: {valid_file}")
3136

37+
3238
if __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}\nError details: {e}")
43-
49+
4450
# Print a summary of all failed files
4551
if failed_files:
4652
print("\nThe following files failed validation:")

0 commit comments

Comments
 (0)