diff --git a/Makefile b/Makefile index 482777da..1a2d41f7 100644 --- a/Makefile +++ b/Makefile @@ -34,7 +34,7 @@ tests/cli.toml: @echo "In order to configure the tests to talk to your test server, you might need to edit $@ ." test: | tests/cli.toml - python3 -m pytest -v tests pulp-glue/tests + python3 -m pytest -v tests pulp-glue/tests cookiecutter/pulp_filter_extension.py docs: pulp-docs build diff --git a/cookiecutter/ci/{{ cookiecutter.__project_name }}/Makefile b/cookiecutter/ci/{{ cookiecutter.__project_name }}/Makefile index a7680ce6..6d721b15 100644 --- a/cookiecutter/ci/{{ cookiecutter.__project_name }}/Makefile +++ b/cookiecutter/ci/{{ cookiecutter.__project_name }}/Makefile @@ -50,6 +50,7 @@ tests/cli.toml: test: | tests/cli.toml python3 -m pytest -v tests {%- if cookiecutter.glue %} pulp-glue{{ cookiecutter.__app_label_suffix }}/tests {%- endif %} + {%- if cookiecutter.__app_label_suffix == "" %} cookiecutter/pulp_filter_extension.py {%- endif %} {%- if cookiecutter.docs %} docs: diff --git a/cookiecutter/pulp_filter_extension.py b/cookiecutter/pulp_filter_extension.py index 9729aaaa..6a6239a4 100644 --- a/cookiecutter/pulp_filter_extension.py +++ b/cookiecutter/pulp_filter_extension.py @@ -51,13 +51,18 @@ def to_jaml(data: t.Any, level: int = 0, embed_in: str = "") -> str: else: raise NotImplementedError("This object is not serializable.") if nl: - return "\n" + " " * level + result + result = "\n" + " " * level + result elif embed_in in ("dict", "list"): - return " " + result + result = " " + result elif embed_in == "document": if level != 0: warnings.warn("jaml: Level should be 0 when embedding in 'document'.") return result + else: + if level != 0: + warnings.warn("jaml: Level should be 0 when serializing a docoment.") + result = "---\n" + result + "\n...\n" + return result def to_toml_value(value: t.Any) -> str: @@ -108,14 +113,14 @@ def __init__(self, environment: Environment): [ ([], 0, "", "---\n[]\n...\n"), ({}, 0, "", "---\n{}\n...\n"), - ("test", 0, "", '---\n"test\n...\n"'), + ("test", 0, "", '---\n"test"\n...\n'), ("test", 0, "document", '"test"'), ({}, 1, "dict", " {}"), ([], 1, "list", " []"), ({}, 1, "list", " {}"), ([], 1, "dict", " []"), - ([{}], 0, "", "- {}"), - ([[[]]], 0, "", "- - []"), + ([{}], 0, "", "---\n- {}\n...\n"), + ([[[]]], 0, "document", "- - []"), ( {"a": [], "b": "test", "c": [True, False]}, 2, @@ -126,7 +131,8 @@ def __init__(self, environment: Environment): - true - false""", ), - ({"b": 1, "a": 0}, 0, "", "a: 0\nb: 1"), + ({"b": 1, "a": 0}, 0, "document", "a: 0\nb: 1"), + ({"b": 1, "a": 0}, 0, "", "---\na: 0\nb: 1\n...\n"), ], ) def test_to_jaml(value, level, embed_in, out): diff --git a/test_requirements.txt b/test_requirements.txt index c1b77a19..15a30398 100644 --- a/test_requirements.txt +++ b/test_requirements.txt @@ -3,6 +3,7 @@ pytest>=7.0.0,<8.4 pytest-subtests>=0.12.0,<0.14 python-gnupg>=0.5.0,<0.6 trustme>=1.1.0,<1.3 +jinja2>=3.1.4,<3.2 # No pinning here, because we only switch on optional dependencies here. pygments