12rambau / pytest-copie

The pytest plugin for your copier templates 📒
https://pytest-copie.readthedocs.io/en/latest/
MIT License
14 stars 2 forks source link

!include config does not work #82

Closed nicokant closed 1 month ago

nicokant commented 2 months ago

Describe the bug Trying to run the test on a project with split configuration does not work.

A simple test produces the following error:

 <Result expected a single document in the stream\n  in "<unicode string>", line 2, column 1:\n    !include src/includes/shared.yml\n    ^\nbut found another document\n  in "<unicode string>", line 3, column 1:\n    ---\n    ^>.exit_code

To Reproduce at the start of your copier.yml add:

---
!include example.yml
---

then create a new example.yml with a question

Run pytest

test_file.py

def test_template_with_extra_answers(copie):
    result = copie.copy()
    assert result.exit_code == 0
12rambau commented 2 months ago

I'm simply not aware of this mechanism from copier, can you point me to a documentation so I can understand what needs to be changed from my side ?

nicokant commented 2 months ago

Of course :) https://copier.readthedocs.io/en/stable/configuring/#include-other-yaml-files

davidbrownell commented 1 month ago

I believe that this can be fixed by changing the call yaml.safe_load to yaml.safe_load_all at https://github.com/12rambau/pytest-copie/blob/8c74beb10c0ca4fa1e79ae2b48793f81ff0540d7/pytest_copie/plugin.py#L74.

Additional information can be found at https://stackoverflow.com/a/14404103.

I've created the fix at Support for `copier.yaml` files that include other files by davidbrownell · Pull Request #83 · 12rambau/pytest-copie (github.com).

12rambau commented 1 month ago

Fixed in #84