예제 #1
0
def test_invalid_config_data(conf_path, flags, check_err, capsys):
    template = Template(conf_path)
    with pytest.raises(InvalidConfigFileError):
        template.config_data
    if check_err:
        _, err = capsys.readouterr()
        assert check_err(err)
예제 #2
0
def test_valid_multi_section(tmp_path):
    """Including multiple files works fine merged with multiple sections."""
    with local.cwd(tmp_path):
        build_file_tree({
            "exclusions.yml":
            "_exclude: ['*.yml']",
            "common_jinja.yml":
            """
                    _envops:
                        block_start_string: "[%"
                        block_end_string: "%]"
                        comment_start_string: "[#"
                        comment_end_string: "#]"
                        variable_start_string: "[["
                        variable_end_string: "]]"
                        keep_trailing_newline: true
                    """,
            "common_questions.yml":
            """
                    your_age:
                        type: int
                    your_name:
                        type: yaml
                        help: your name from common questions
                    """,
            "copier.yml":
            """
                    ---
                    !include 'common_*.yml'
                    ---
                    !include exclusions.yml
                    ---
                    your_name:
                        type: str
                        help: your name from latest section
                    """,
        })
    template = Template(str(tmp_path))
    assert template.exclude == ("*.yml", )
    assert template.envops == {
        "autoescape": False,
        "block_end_string": "%]",
        "block_start_string": "[%",
        "comment_end_string": "#]",
        "comment_start_string": "[#",
        "keep_trailing_newline": True,
        "variable_end_string": "]]",
        "variable_start_string": "[[",
    }
    assert template.questions_data == {
        "your_age": {
            "type": "int"
        },
        "your_name": {
            "type": "str",
            "help": "your name from latest section"
        },
    }
예제 #3
0
def test_config_data_is_loaded_from_file():
    tpl = Template("tests/demo_data")
    assert tpl.exclude == ("exclude1", "exclude2")
    assert tpl.skip_if_exists == ["skip_if_exists1", "skip_if_exists2"]
    assert tpl.tasks == ["touch 1", "touch 2"]
예제 #4
0
def test_multiple_config_file_error():
    template = Template("tests/demo_multi_config")
    with pytest.raises(MultipleConfigFilesError):
        template.config_data
예제 #5
0
def test_config_data_empty():
    template = Template("tests/demo_config_empty")
    assert template.config_data == {"secret_questions": set()}
    assert template.questions_data == {}