mirror of
https://github.com/copier-org/copier.git
synced 2025-05-05 23:42:55 +00:00
* use a new toolkit for user prompting: questionary (patched). * multiline questions. * conditional questions. * new toolkit for ui tests: pexpect. * fix lots of tests. * fix windows builds with newer poetry-dynamic-versioning. * linters and mypy are now tests, to have faster ci. * update deprecated ci commands. * removed dependencies from old times. * Remove toml 0.5+ syntax (dotted keys) * Use powershell where syntax is compatible * Change skip to xfail * xfail pexpect tests on windows. I'm tired of trying to make it work * more docs * possibly something more.
74 lines
1.9 KiB
Python
74 lines
1.9 KiB
Python
from pathlib import Path
|
|
|
|
import pytest
|
|
from poethepoet.app import PoeThePoet
|
|
|
|
from copier import tools
|
|
from copier.config.factory import ConfigData, EnvOps
|
|
|
|
from .helpers import DATA, PROJECT_TEMPLATE
|
|
|
|
|
|
def test_render(tmp_path):
|
|
envops = EnvOps().dict()
|
|
render = tools.Renderer(
|
|
ConfigData(
|
|
src_path=PROJECT_TEMPLATE,
|
|
dst_path=tmp_path,
|
|
data_from_init=DATA,
|
|
envops=envops,
|
|
)
|
|
)
|
|
|
|
assert render.string("/hello/[[ what ]]/") == "/hello/world/"
|
|
assert render.string("/hello/world/") == "/hello/world/"
|
|
|
|
sourcepath = PROJECT_TEMPLATE / "pyproject.toml.tmpl"
|
|
result = render(sourcepath)
|
|
expected = Path("./tests/reference_files/pyproject.toml").read_text()
|
|
assert result == expected
|
|
|
|
|
|
TEST_PATTERNS = (
|
|
# simple file patterns and their negations
|
|
"*.exclude",
|
|
"!do_not.exclude",
|
|
# dir patterns and their negations
|
|
"exclude_dir/",
|
|
"!exclude_dir/please_copy_me",
|
|
"!not_exclude_dir/x",
|
|
# unicode patterns
|
|
"mañana.txt",
|
|
)
|
|
path_filter = tools.create_path_filter(TEST_PATTERNS)
|
|
|
|
|
|
@pytest.mark.parametrize(
|
|
"pattern,should_match",
|
|
(
|
|
# simple file patterns and their negations
|
|
("x.exclude", True),
|
|
("do_not.exclude!", False),
|
|
# dir patterns and their negations
|
|
("exclude_dir/x", True),
|
|
("exclude_dir/please_copy_me", False), # no mercy
|
|
("not_exclude_dir/x!", False),
|
|
# unicode patterns
|
|
("mañana.txt", True),
|
|
("mañana.txt", False),
|
|
("manana.txt", False),
|
|
),
|
|
)
|
|
def test_create_path_filter(pattern, should_match):
|
|
assert path_filter(pattern) == should_match
|
|
|
|
|
|
def test_lint():
|
|
"""Ensure source code formatting"""
|
|
PoeThePoet(Path("."))(["lint", "--show-diff-on-failure", "--color=always"])
|
|
|
|
|
|
def test_types():
|
|
"""Ensure source code static typing."""
|
|
PoeThePoet(Path("."))(["types"])
|