Skip to content

Snapshots do not support directives for worldgen #361

Open
@BPR02

Description

@BPR02

lectern v0.34.0
beet v0.108.5
pytest v8.3.3
pytest-insta v0.3.0

I'm trying to use lectern snapshots to test my WIP beet plugin, but it appears that overlays aren't properly working with directives for worldgen. Generating the markdown file works fine and generating a datapack from the markdown file also works fine, but when loading the snapshot, there is no overlay in the resulting Document object. Only the worldgen directives are broken. I explicitly tested the following which resulted in the error posted further down:

  • invalid (sanity test)
  • dimension_type
  • dimension
  • biome
  • configured_carver
  • configured_feature
  • configured_structure_feature
  • configured_surface_builder
  • noise_settings
  • processor_list
  • template_pool

This is my python test code, which is basically the same as bolt test

import os
from pathlib import Path

import pytest
from beet import ProjectCache, run_beet
from lectern import Document
from pytest_insta import SnapshotFixture

EXAMPLES = [
    f
    for f in os.listdir("examples")
    if not (f.startswith("nosnap_") or f.startswith("."))
]


@pytest.mark.parametrize("directory", EXAMPLES)
def test_build(snapshot: SnapshotFixture, directory: str, tmp_path: Path):
    with run_beet(
        directory=f"examples/{directory}",
        cache=ProjectCache(tmp_path / ".beet_cache", tmp_path / "generated"),
    ) as ctx:
        expected: Document = snapshot("pack.md")
        actual = ctx.inject(Document)
        assert actual == expected

An example can be found in this branch. Running pytest will result in the error below.
https://github.com/BPR02/Observer/tree/worldgen

FAILED tests/test_examples.py::test_build[overlay_adds_dimension1] - AssertionError: assert Document(assets=ResourcePack(name='overlay_adds_dimension1_resource_pack', description='', pack_format=34), data=DataPack(name='overlay_adds_dimension1_data_pack', description='', pack_format=57)) == Document(assets=ResourcePack(name='overlay_adds_dimension1_resource_pack', description='', pack_format=34), data=DataPack(name='overlay_adds_dimension1_data_pack', description='', pack_format=57))
  
  Differing data pack:
    assert DataPack(name='overlay_adds_dimension1_data_pack', description='', pack_format=57) == DataPack(name='overlay_adds_dimension1_data_pack', description='', pack_format=57)
    
    Differing file:
    ['pack.mcmeta']
    
    Drill down into differing file 'pack.mcmeta':
      assert {'pack': {'pack_format': 57, 'description': '', 'supported_formats': [48, 57]}, 'overlays': {'entries': [{'formats': 48, 'directory': 'overlay_48'}]}} == {'pack': {'pack_format': 57, 'description': '', 'supported_formats': [48, 57]}}
      
      Common items:
      {'pack': {'description': '', 'pack_format': 57, 'supported_formats': [48, 57]}}
      Left contains 1 more item:
      {'overlays': {'entries': [{'directory': 'overlay_48', 'formats': 48}]}}
      
      Full diff:
        {
      +     'overlays': {
      +         'entries': [
      +             {
      +                 'directory': 'overlay_48',
      +                 'formats': 48,
      +             },
      +         ],
      +     },
            'pack': {
                'description': '',
                'pack_format': 57,
                'supported_formats': [
                    48,
                    57,
                ],
            },
        }
    
    Left contains 1 more namespace:
    {'demo': DataPackNamespace()}
    
    Left contains 1 more overlay:
    {'overlay_48': DataPack(name=None, description='', pack_format=0)}

The snapshot below is generated which is valid and can generate the correct datapack, but does not work when loaded as a snapshot.

Lectern snapshot

Data pack

@data_pack pack.mcmeta

{
  "pack": {
    "pack_format": 57,
    "description": "",
    "supported_formats": [
      48,
      57
    ]
  },
  "overlays": {
    "entries": [
      {
        "formats": 48,
        "directory": "overlay_48"
      }
    ]
  }
}

demo

@dimension demo:foo

{
  "type": "demo:this-is-the-same-in-both",
  "generator": {
    "type": "minecraft:debug"
  }
}

Overlay overlay_48

@overlay overlay_48

demo

--VVV-- HERE IS THE ISSUE ----------------------------------
@dimension demo:demo

{
  "type": "demo:this-only-exists-in-the-overlay",
  "generator": {
    "type": "minecraft:debug"
  }
}

@endoverlay

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions