import pytest import main @pytest.fixture(autouse=True) def patch_log(monkeypatch): monkeypatch.setattr(main, "log", lambda msg: None) monkeypatch.setattr(main, "logvv", lambda msg: None) def test_read_csv_to_dict_basic(tmp_path): content = ( "img1\t12.34 56.78\tfoo\tbar\n" "img2\t90.12 34.56\tbaz\tqux\n" ) file_path = tmp_path / "test.csv" file_path.write_text(content, encoding="utf-8") result = main.read_csv_to_dict(str(file_path)) expected = [ ['img1', 12.34, 56.78, 'foo', 'bar'], ['img2', 90.12, 34.56, 'baz', 'qux'], ] assert result == expected def test_read_csv_to_dict_empty_file(tmp_path): file_path = tmp_path / "empty.csv" file_path.write_text("", encoding="utf-8") assert main.read_csv_to_dict(str(file_path)) == None def test_read_csv_to_dict_extra_spaces(tmp_path): content = ( "img3\t 3.23 4.56 \tfoo\tbar\n" ) file_path = tmp_path / "extra_spaces.csv" file_path.write_text(content, encoding="utf-8") result = main.read_csv_to_dict(str(file_path)) expected = [['img3', 3.23, 4.56, 'foo', 'bar']] assert result == expected def test_read_csv_to_dict_incorrect_format(tmp_path): content = ( "img4\t44.34\tfoo\tbar\n" # missing lat in second column ) file_path = tmp_path / "incorrect.csv" file_path.write_text(content, encoding="utf-8") assert main.read_csv_to_dict(str(file_path)) == None