Skip to content

[Question] Injecting a choice value with extra_context not being respected #24

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
heitorlessa opened this issue Jun 15, 2018 · 3 comments
Labels
question Questions about pytest-cookies

Comments

@heitorlessa
Copy link

Hello!

Firstly, thanks for the fantastic project - It's incredibly easy to use :)

I'm using Choices in a new project and while creating tests I noticed that no matter what I pass under extra_context it doesn't get picked up - Using Cookiecutter CLI works just fine (also checked the replay directory to confirm I wasn't passing bad data).

How to reproduce

  • Create a cookiecutter.json with a choice option:
{
 "project_name": "default name",
 "my_options": ["Opt1", "Opt2"]
}
  • Bake with extra_contexts
    result = cookies.bake(extra_context={
        'project_name': '--pytest-cookies--',
        'my_options': "Opt2"
    })

It will default to Opt1 even though we pass Opt2 in the extra context.

I'll do further debugging here but in case anyone can easily spot the issue (one of those days that you spend too much time looking at a problem and can't see the obvious).

Obrigado!!

@hackebrot
Copy link
Owner

Hi @heitorlessa! 👋

Thank you for the feedback. It is much appreciated!

I created a test for what you're describing in #25. I can't seem to be able to replicate this issue.

Can you please check out the branch locally and see if it fails for you?

@hackebrot hackebrot added the question Questions about pytest-cookies label Jun 18, 2018
@heitorlessa
Copy link
Author

That was quick! Sure thing.. I'm working on another set of tests for Travis now and will retry hopefully this week and give you an update.

@heitorlessa
Copy link
Author

I couldn't wait until mid-week and took a peak at the tests - Checked that PR locally and everything works just as expected so I went on to check my tests and found the issue: misspelled one letter of the expected value from the choices and within reason it kept defaulting to the first option :(.

Told ya I spent too much time at the computer and couldn't see the obvious - Apologies for the unnecessary issue but glad that this wasn't captured under tests so a win-win ;)

Thanks again and I'm resolving this now @hackebrot.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
question Questions about pytest-cookies
Projects
None yet
Development

No branches or pull requests

2 participants