mirror of
https://github.com/azaion/ai-training.git
synced 2026-04-22 10:36:35 +00:00
41552c5699
Made-with: Cursor
40 lines
1.2 KiB
Python
40 lines
1.2 KiB
Python
import sys
|
|
import types
|
|
|
|
for _name in ("ultralytics", "boto3", "netron", "requests"):
|
|
if _name not in sys.modules:
|
|
sys.modules[_name] = types.ModuleType(_name)
|
|
sys.modules["ultralytics"].YOLO = type("YOLO", (), {})
|
|
sys.modules["boto3"].client = lambda *a, **k: None
|
|
|
|
from train import check_label
|
|
|
|
|
|
def test_bt_lbl_01_valid_label_returns_true(tmp_path):
|
|
p = tmp_path / "a.txt"
|
|
p.write_text("0 0.5 0.5 0.1 0.1", encoding="utf-8")
|
|
assert check_label(str(p)) is True
|
|
|
|
|
|
def test_bt_lbl_02_x_gt_one_returns_false(tmp_path):
|
|
p = tmp_path / "a.txt"
|
|
p.write_text("0 1.5 0.5 0.1 0.1", encoding="utf-8")
|
|
assert check_label(str(p)) is False
|
|
|
|
|
|
def test_bt_lbl_03_height_gt_one_returns_false(tmp_path):
|
|
p = tmp_path / "a.txt"
|
|
p.write_text("0 0.5 0.5 0.1 1.2", encoding="utf-8")
|
|
assert check_label(str(p)) is False
|
|
|
|
|
|
def test_bt_lbl_04_missing_file_returns_false(tmp_path):
|
|
p = tmp_path / "missing.txt"
|
|
assert check_label(str(p)) is False
|
|
|
|
|
|
def test_bt_lbl_05_multiline_one_corrupted_returns_false(tmp_path):
|
|
p = tmp_path / "a.txt"
|
|
p.write_text("0 0.5 0.5 0.1 0.1\n3 0.5 0.5 0.1 1.5", encoding="utf-8")
|
|
assert check_label(str(p)) is False
|