-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathtest_abif_scan.py
More file actions
executable file
·40 lines (32 loc) · 1.17 KB
/
test_abif_scan.py
File metadata and controls
executable file
·40 lines (32 loc) · 1.17 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
#!/usr/bin/env python3
"""
test_abif_scan.py - Scans for .abif files and runs basic tests on them.
This test discovers all .abif files in the project directory structure
and runs a basic validation test against each file.
"""
import abif
import os
import pathlib
import pytest
import sys
import typing
EXTRA_ABIF_DIR="extra_abif"
def find_all_abif_files(abif_dir_to_scan) -> typing.List[pathlib.Path]:
"""Find all .abif files in all subdirectories."""
root_dir = pathlib.Path(abif_dir_to_scan)
abif_files = list(root_dir.glob("**/*.abif"))
return sorted(abif_files)
@pytest.mark.parametrize("abif_file", find_all_abif_files(EXTRA_ABIF_DIR))
def test_is_abif_valid(abif_file):
"""Test that each .abif file exists and can be read."""
assert abif_file.exists(), f"ABIF file {abif_file} does not exist"
jabmod = abif.convert_abif_file_to_jabmod(abif_file)
if __name__ == "__main__":
if len(sys.argv) > 1:
files = find_all_abif_files(sys.argv[1])
else:
files = find_all_abif_files(EXTRA_ABIF_DIR)
print(f"Found {len(files)} ABIF files:")
for file in files:
print(f" {file}")
jabmod = abif.convert_abif_file_to_jabmod(file)