Skip to content

Commit

Permalink
Increase timeout for pexpect and use yaml.load_safe
Browse files Browse the repository at this point in the history
  • Loading branch information
Jairo Llopis committed Oct 8, 2020
1 parent 0b8a9a9 commit 7f3477d
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 8 deletions.
4 changes: 2 additions & 2 deletions tests/test_complex_questions.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ def test_cli_interactive(tmp_path):
"Invalid value",
"please try again",
]
tui = pexpect.spawn("copier", ["copy", SRC, str(tmp_path)], timeout=3)
tui = pexpect.spawn("copier", ["copy", SRC, str(tmp_path)], timeout=5)
tui.expect_exact(["I need to know it. Do you love me?", "love_me", "Format: bool"])
tui.send("y")
tui.expect_exact(["Please tell me your name.", "your_name", "Format: str"])
Expand Down Expand Up @@ -192,7 +192,7 @@ def test_cli_interatively_with_flag_data_and_type_casts(tmp_path: Path):
SRC,
str(tmp_path),
],
timeout=3,
timeout=5,
)

tui.expect_exact(["I need to know it. Do you love me?", "love_me", "Format: bool"])
Expand Down
4 changes: 2 additions & 2 deletions tests/test_migrations.py
Original file line number Diff line number Diff line change
Expand Up @@ -181,7 +181,7 @@ def test_prereleases(tmp_path: Path):
git("tag", "v2.0.0.alpha1")
# Copying with use_prereleases=False copies v1
copy(src_path=str(src), dst_path=dst, force=True)
answers = yaml.load((dst / ".copier-answers.yml").read_text())
answers = yaml.load_safe((dst / ".copier-answers.yml").read_text())
assert answers["_commit"] == "v1.0.0"
assert (dst / "version.txt").read_text() == "v1.0.0"
assert not (dst / "v1.9").exists()
Expand All @@ -204,7 +204,7 @@ def test_prereleases(tmp_path: Path):
assert not (dst / "v2.a2").exists()
# Update it with prereleases
copy(dst_path=dst, force=True, use_prereleases=True)
answers = yaml.load((dst / ".copier-answers.yml").read_text())
answers = yaml.load_safe((dst / ".copier-answers.yml").read_text())
assert answers["_commit"] == "v2.0.0.alpha1"
assert (dst / "version.txt").read_text() == "v2.0.0.alpha1"
assert (dst / "v1.9").exists()
Expand Down
6 changes: 3 additions & 3 deletions tests/test_prompt.py
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ def test_copy_default_advertised(tmp_path_factory, name):
git("add", ".")
assert "_commit: v1" in Path(".copier-answers.yml").read_text()
git("commit", "-m", "v1")
tui = pexpect.spawn("copier", timeout=3)
tui = pexpect.spawn("copier", timeout=5)
# Check what was captured
tui.expect_exact(["in_love?", "Format: bool", "(Y/n)"])
tui.sendline()
Expand Down Expand Up @@ -138,7 +138,7 @@ def test_when(tmp_path_factory, question_2_when, asks):
tui.expect_exact(["question_2?", "Format: yaml"])
tui.sendline()
tui.expect_exact(pexpect.EOF)
answers = yaml.load((subproject / ".copier-answers.yml").read_text())
answers = yaml.load_safe((subproject / ".copier-answers.yml").read_text())
assert answers == {
"_src_path": str(template),
"question_1": True,
Expand Down Expand Up @@ -176,7 +176,7 @@ def test_placeholder(tmp_path_factory):
)
tui.sendline()
tui.expect_exact(pexpect.EOF)
answers = yaml.load((subproject / ".copier-answers.yml").read_text())
answers = yaml.load_safe((subproject / ".copier-answers.yml").read_text())
assert answers == {
"_src_path": str(template),
"question_1": "answer 1",
Expand Down
2 changes: 1 addition & 1 deletion tests/test_templated_prompt.py
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,7 @@ def test_templated_prompt(
tui.expect_exact([f"{question_name}?"] + expected_outputs)
tui.sendline()
tui.expect_exact(pexpect.EOF)
answers = yaml.load((subproject / ".copier-answers.yml").read_text())
answers = yaml.load_safe((subproject / ".copier-answers.yml").read_text())
assert answers[question_name] == expected_value


Expand Down

0 comments on commit 7f3477d

Please sign in to comment.