Coverage for scripts/tests/test_remap_classid.py: 100%
11 statements
« prev ^ index » next coverage.py v7.10.2, created at 2025-08-07 15:22 +0000
« prev ^ index » next coverage.py v7.10.2, created at 2025-08-07 15:22 +0000
1# tests/test_label_utils.py
2import os
3from scripts.annotations.remap_classid import change_annotation_labels
5def test_change_annotation_labels(tmp_path):
6 # Setup test directory and files
7 label_dir = tmp_path / "labels"
8 label_dir.mkdir()
10 # Create a test label file
11 file_path = label_dir / "test1.txt"
12 file_path.write_text("2 0.5 0.5 0.1 0.1\n3 0.6 0.6 0.1 0.1\n")
13 label_map = {
14 '2': '5',
15 }
16 # Run the function
17 change_annotation_labels(str(label_dir), label_map)
19 # Read the modified content
20 result = file_path.read_text()
22 # Assert the label was changed according to the mapping
23 assert result == "5 0.5 0.5 0.1 0.1\n3 0.6 0.6 0.1 0.1\n"