12
12
import tensorflow as tf
13
13
import tensorflow_hub as hub
14
14
from numpy .testing import assert_array_equal , assert_allclose
15
+ from sleap .io .video import available_video_exts
15
16
16
17
import sleap
17
18
from sleap .gui .learning import runners
@@ -1556,12 +1557,10 @@ def test_sleap_track_mult_input_slp(
1556
1557
sleap_track (args = args )
1557
1558
1558
1559
# Assert predictions file exists
1559
- expected_extensions = {
1560
- ".mp4" ,
1561
- } # Add other video formats if necessary
1560
+ expected_extensions = available_video_exts ()
1562
1561
1563
1562
for file_path in slp_path_list :
1564
- if file_path in expected_extensions :
1563
+ if file_path . suffix in expected_extensions :
1565
1564
expected_output_file = Path (file_path ).with_suffix (".predictions.slp" )
1566
1565
assert Path (expected_output_file ).exists ()
1567
1566
@@ -1602,9 +1601,10 @@ def test_sleap_track_mult_input_slp_mp4(
1602
1601
# Run inference
1603
1602
sleap_track (args = args )
1604
1603
1605
- # Assert predictions file exists
1604
+ expected_extensions = available_video_exts ()
1605
+
1606
1606
for file_path in slp_path_list :
1607
- if file_path .suffix == ".mp4" :
1607
+ if file_path .suffix in expected_extensions :
1608
1608
expected_output_file = Path (file_path ).with_suffix (".predictions.slp" )
1609
1609
assert Path (expected_output_file ).exists ()
1610
1610
@@ -1643,8 +1643,10 @@ def test_sleap_track_mult_input_mp4(
1643
1643
sleap_track (args = args )
1644
1644
1645
1645
# Assert predictions file exists
1646
+ expected_extensions = available_video_exts ()
1647
+
1646
1648
for file_path in slp_path_list :
1647
- if file_path .suffix == ".mp4" :
1649
+ if file_path .suffix in expected_extensions :
1648
1650
expected_output_file = Path (file_path ).with_suffix (".predictions.slp" )
1649
1651
assert Path (expected_output_file ).exists ()
1650
1652
@@ -1686,8 +1688,10 @@ def test_sleap_track_output_mult(
1686
1688
slp_path = Path (slp_path )
1687
1689
1688
1690
# Check if there are any files in the directory
1691
+ expected_extensions = available_video_exts ()
1692
+
1689
1693
for file_path in slp_path_list :
1690
- if file_path .suffix == ".mp4" :
1694
+ if file_path .suffix in expected_extensions :
1691
1695
expected_output_file = output_path_obj / (
1692
1696
file_path .stem + ".predictions.slp"
1693
1697
)
@@ -1808,8 +1812,10 @@ def test_sleap_track_csv_input(
1808
1812
sleap_track (args = args )
1809
1813
1810
1814
# Assert predictions file exists
1815
+ expected_extensions = available_video_exts ()
1816
+
1811
1817
for file_path in slp_path_list :
1812
- if file_path .suffix == ".mp4" :
1818
+ if file_path .suffix in expected_extensions :
1813
1819
expected_output_file = file_path .with_suffix (".TESTpredictions.slp" )
1814
1820
assert Path (expected_output_file ).exists ()
1815
1821
@@ -1839,7 +1845,7 @@ def test_sleap_track_invalid_csv(
1839
1845
).split ()
1840
1846
1841
1847
# Run inference and expect ValueError for missing 'data_path' column
1842
- with pytest .raises (ValueError ):
1848
+ with pytest .raises (ValueError , match = f"Column containing valid data_paths does not exist in the CSV file: { csv_missing_column_path } " ):
1843
1849
sleap_track (args = args_missing_column )
1844
1850
1845
1851
# Create sleap-track command for empty CSV file
@@ -1850,7 +1856,7 @@ def test_sleap_track_invalid_csv(
1850
1856
).split ()
1851
1857
1852
1858
# Run inference and expect ValueError for empty CSV file
1853
- with pytest .raises (ValueError ):
1859
+ with pytest .raises (ValueError , match = f"CSV file is empty: { csv_empty_path } " ):
1854
1860
sleap_track (args = args_empty )
1855
1861
1856
1862
@@ -1894,8 +1900,10 @@ def test_sleap_track_text_file_input(
1894
1900
sleap_track (args = args )
1895
1901
1896
1902
# Assert predictions file exists
1903
+ expected_extensions = available_video_exts ()
1904
+
1897
1905
for file_path in slp_path_list :
1898
- if file_path .suffix == ".mp4" :
1906
+ if file_path .suffix in expected_extensions :
1899
1907
expected_output_file = Path (file_path ).with_suffix (".predictions.slp" )
1900
1908
assert Path (expected_output_file ).exists ()
1901
1909
0 commit comments