MCPcopy
hub / github.com/copier-org/copier / test_folder_loop

Function test_folder_loop

tests/test_dynamic_file_structures.py:11–43  ·  view source on GitHub ↗
(tmp_path_factory: pytest.TempPathFactory)

Source from the content-addressed store, hash-verified

9
10
11def test_folder_loop(tmp_path_factory: pytest.TempPathFactory) -> None:
12 src, dst = map(tmp_path_factory.mktemp, ("src", "dst"))
13 build_file_tree(
14 {
15 src / "copier.yml": "",
16 src
17 / "folder_loop"
18 / "{% yield item from strings %}{{ item }}{% endyield %}"
19 / "{{ item }}.txt.jinja": "Hello {{ item }}",
20 }
21 )
22 with warnings.catch_warnings():
23 warnings.simplefilter("error")
24 copier.run_copy(
25 str(src),
26 dst,
27 data={
28 "strings": ["a", "b", "c"],
29 },
30 defaults=True,
31 overwrite=True,
32 )
33
34 expected_files = [dst / f"folder_loop/{i}/{i}.txt" for i in ["a", "b", "c"]]
35
36 for f in expected_files:
37 assert f.exists()
38 assert f.read_text() == f"Hello {f.parent.name}"
39
40 all_files = [p for p in dst.rglob("*") if p.is_file()]
41 unexpected_files = set(all_files) - set(expected_files)
42
43 assert not unexpected_files, f"Unexpected files found: {unexpected_files}"
44
45
46def test_folder_loop_reports_path_when_yielded_part_rendering_fails(

Callers

nothing calls this directly

Calls 2

build_file_treeFunction · 0.90
run_copyMethod · 0.80

Tested by

no test coverage detected