MockContext does not honor "warn=False" which is the default behaviour
Nobody has claimed this yet.
Assessment
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Newbie friendliness
- 45/100
Research direction
Start by tracing MockContext handling of ctx.run with a Result whose exited value is nonzero, paying attention to the default warn=False behavior described in the issue. Reproduce the scenario in the MockContext tests and verify that a nonzero exit causes the expected failure unless warning behavior is explicitly enabled.
Written by the indexing model from the issue text.
Description
I just ran into an issue where my test wasn't catching a bug I had because of this.
I gracefully catch errors:
result = ctx.run("my command", hide=False, echo=True)
if result.exited:
... do stuff
Now I forgot to add warn=True here, but wrote my tests with MockContext:
ctx = MockContext(
run={
"my command": Result("Mock output", exited=1),
}
)
... and checked the "do stuff" after the command returned a non-zero exit code worked as expected
My tests were passing without issue because MockContext isn't honoring the default warn=False. I found in production the error was not being caught because I forgot to set warn=True.
What should have happened was:
- MockContext sees
warn=Falseand pyinvoke immediately exits after the command returns a non-zero exit code - My tests fail and I catch the misconfiguration
- Dominant language
- Python
- Stars
- 4.8k
- Forks
- 412
- PR merge metrics
- No merged PRs in 30d
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from pyinvoke/invoke
-
[Security] Shell injection via Context.cd() path argument — metacharacters not escaped (CWE-78) Open
Difficulty 2/5 1-3 hours Newbie friendliness 72/100
-
Difficulty 2/5 1-3 hours Newbie friendliness 70/100
-
Difficulty 2/5 1-3 hours Newbie friendliness 76/100
-
Difficulty 2/5 1-3 hours Newbie friendliness 70/100
-
Difficulty 2/5 1-3 hours Newbie friendliness 64/100
Similar issues
-
essnmx good first issue
Difficulty 1/5 Under an hour Newbie friendliness 95/100
-
[Feature] 奇物选择添加优先级 Open
Difficulty 2/5 1-3 hours Newbie friendliness 65/100
syfoud/Simulated_Scepter#174 ·
-
Difficulty 2/5 1-3 hours Newbie friendliness 75/100
Giskard-AI/giskard-oss#2840 · 1 comment ·
-
A claim comment carrying the issue number is silently declined while the workflow reports success Openarea: repo bug perceived difficulty: 2
Difficulty 2/5 1-3 hours Newbie friendliness 70/100
-
Difficulty 2/5 1-3 hours Newbie friendliness 75/100
yeti-platform/yeti#1380 ·