import pytest import byml.yaml_util import oead import yaml from utils import make_test_cases cases, data = make_test_cases("byml/files/*.yml") byml.yaml_util.add_constructors(yaml.CLoader) def byml_parse(data): return yaml.load(data, Loader=yaml.CLoader) @pytest.mark.parametrize("file", cases) def test_parse_byml(benchmark, file): benchmark.group = "from_text: " + file benchmark(byml_parse, data[file]) @pytest.mark.parametrize("file", cases) def test_parse_oead(benchmark, file): benchmark.group = "from_text: " + file benchmark(oead.byml.from_text, data[file])
import pytest import oead from utils import make_test_cases cases_bin, data_bin = make_test_cases("gsheet/files/*.gsheet") @pytest.mark.parametrize("file", cases_bin) def test_gsheet_roundtrip_bin(file): sheet = oead.gsheet.parse(data_bin[file]) serialized = sheet.to_binary() assert data_bin[file] == serialized
import pytest import oead from utils import make_test_cases cases_bin, data_bin = make_test_cases("byml/files/*.byml") cases_text, data_text = make_test_cases("byml/files/*.yml") @pytest.mark.parametrize("file", cases_bin) def test_byml_roundtrip_bin(file): data = oead.byml.from_binary(data_bin[file]) serialized = oead.byml.to_binary(data, big_endian=False, version=2) data2 = oead.byml.from_binary(serialized) assert data == data2 @pytest.mark.parametrize("file", cases_bin) def test_byml_roundtrip_bin_big_endian(file): data = oead.byml.from_binary(data_bin[file]) serialized = oead.byml.to_binary(data, big_endian=True, version=2) data2 = oead.byml.from_binary(serialized) assert data == data2 @pytest.mark.parametrize("file", cases_text) def test_byml_roundtrip_text(file): data = oead.byml.from_text(data_text[file]) serialized = oead.byml.to_text(data) data2 = oead.byml.from_text(serialized) assert data == data2
import pytest import oead from utils import make_test_cases cases, cases_data = make_test_cases("sarc/files/*.sarc") @pytest.mark.parametrize("file", cases) def test_sarc_get_file(file): arc = oead.Sarc(cases_data[file]) for sarc_file in arc.get_files(): assert arc.get_file(sarc_file.name) is not None