(
tmp_path_factory: pytest.TempPathFactory, spawn: Spawn, type_: str
)
| 569 | |
| 570 | @pytest.mark.parametrize("type_", ["str", "yaml", "json"]) |
| 571 | def test_multiline( |
| 572 | tmp_path_factory: pytest.TempPathFactory, spawn: Spawn, type_: str |
| 573 | ) -> None: |
| 574 | src, dst = map(tmp_path_factory.mktemp, ("src", "dst")) |
| 575 | build_file_tree( |
| 576 | { |
| 577 | (src / "copier.yml"): yaml.dump( |
| 578 | { |
| 579 | "_envops": BRACKET_ENVOPS, |
| 580 | "_templates_suffix": SUFFIX_TMPL, |
| 581 | "question_1": "answer 1", |
| 582 | "question_2": {"type": type_}, |
| 583 | "question_3": {"type": type_, "multiline": True}, |
| 584 | "question_4": { |
| 585 | "type": type_, |
| 586 | "multiline": "[[ question_1 == 'answer 1' ]]", |
| 587 | }, |
| 588 | "question_5": { |
| 589 | "type": type_, |
| 590 | "multiline": "[[ question_1 != 'answer 1' ]]", |
| 591 | }, |
| 592 | } |
| 593 | ), |
| 594 | (src / "[[ _copier_conf.answers_file ]].tmpl"): ( |
| 595 | "[[ _copier_answers|to_nice_yaml ]]" |
| 596 | ), |
| 597 | } |
| 598 | ) |
| 599 | tui = spawn(COPIER_PATH + ("copy", str(src), str(dst))) |
| 600 | expect_prompt(tui, "question_1", "str") |
| 601 | tui.expect_exact("answer 1") |
| 602 | tui.sendline() |
| 603 | expect_prompt(tui, "question_2", type_) |
| 604 | tui.sendline('"answer 2"') |
| 605 | expect_prompt(tui, "question_3", type_) |
| 606 | tui.sendline('"answer 3"') |
| 607 | tui.send(Keyboard.Alt + Keyboard.Enter) |
| 608 | expect_prompt(tui, "question_4", type_) |
| 609 | tui.sendline('"answer 4"') |
| 610 | tui.send(Keyboard.Alt + Keyboard.Enter) |
| 611 | expect_prompt(tui, "question_5", type_) |
| 612 | tui.sendline('"answer 5"') |
| 613 | tui.expect_exact(pexpect.EOF) |
| 614 | answers = load_answersfile_data(dst) |
| 615 | if type_ == "str": |
| 616 | assert answers == { |
| 617 | "_src_path": str(src), |
| 618 | "question_1": "answer 1", |
| 619 | "question_2": '"answer 2"', |
| 620 | "question_3": ('"answer 3"\n'), |
| 621 | "question_4": ('"answer 4"\n'), |
| 622 | "question_5": ('"answer 5"'), |
| 623 | } |
| 624 | else: |
| 625 | assert answers == { |
| 626 | "_src_path": str(src), |
| 627 | "question_1": "answer 1", |
| 628 | "question_2": ("answer 2"), |
nothing calls this directly
no test coverage detected