Files
RustNotMC/tests/test_prepare_exporters.py
SashegDev 874b6f20c2 Клиент: начальный импорт кодовой базы
Основа — Horizon (MIT). История апстрима не переносится: этот репозиторий ведёт свою.
2026-10-29 22:04:28 +03:00

38 lines
1.8 KiB
Python

"""The release comparison must tolerate only known variation and still catch regressions."""
import contextlib
import io
import json
from pathlib import Path
import tempfile
import unittest
from tools.check_prepare_exporters import verify
class PrepareExportersTests(unittest.TestCase):
def test_known_noise_does_not_mask_changed_resources(self):
with tempfile.TemporaryDirectory() as temporary:
folders = [Path(temporary) / str(i) for i in range(3)]
for i, folder in enumerate(folders):
folder.mkdir()
(folder / 'stable.nbt').write_bytes(b'unchanged')
(folder / 'horizon-resources.json').write_text('{"schema":7}')
(folder / 'block-behaviours.json').write_text(json.dumps({
'fields': {'shape': f'<Block$$Lambda/0x{i:08x}>', 'solid': True}}))
(folder / 'creative-inventory.json').write_text(json.dumps({
'tabs': [{}, {'tags': [['a', 'b'] if i < 2 else ['b', 'a']], 'items': ['stone']}]}))
with contextlib.redirect_stdout(io.StringIO()):
verify(folders)
for name, changed in [
('stable.nbt', b'changed'),
('block-behaviours.json', b'{"fields":{"shape":"<Block$$Lambda/0x1234>","solid":false}}'),
('creative-inventory.json', b'{"tabs":[{},{"tags":[["a","b"]],"items":["dirt"]}]}'),
('horizon-resources.json', b'{"schema":8}'),
]:
path = folders[2] / name
original = path.read_bytes()
path.write_bytes(changed)
with self.subTest(resource=name), self.assertRaises(SystemExit):
verify(folders)
path.write_bytes(original)