-
Notifications
You must be signed in to change notification settings - Fork 23
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
"Undefined template variable" During pytest Runs #134
Comments
@Dresdn which version of cotton are you on? |
The original post was using 0.9.38. I just updated it to 0.9.40 and have the same results. As an FYI, I was thinking that the way pytest loads Django, maybe something was being loaded/read too soon, so I tried using the implicit registration. That had the same results. Editing to add other versions: django = "4.2.11" |
Since I'm in it, here's what the
|
@Dresdn I wasn't able to replicate with
python 3.11 I recommend trying to create in a minimal reproducible.. |
Thanks for taking a look. I wasn't able to reproduce in a fresh project either. I hoped something was glaringly missing, so I'll keep stripping down the project to see if I can pinpoint anything. Feel free to close or leave this open, but it'll take me a few days to really get into this. |
@wrabit I couldn't let it go, but I figured out what is causing the failure. In our pyteset options, we use pytest-django's The challenge is, looking at what they're doing for this option, I'm not sure if there's a good way to solve this on the Cotton end. I'm thinking I'll submit an MR there to allow ignoring template directories or something. |
@Dresdn I did have a play with this and even when I tried to catch the exception in cotton, it still seemed to trigger the fail on pytest.. |
This looks to be pretty core to Django since the django-pytest team is setting the AdamChainz wrote an interesting blog about the perils of doing so, and it seems we're hitting the |
Actually, if anything, maybe just a note about |
Ah makes sense, that's what's behind the defaults for cvars. I'll make a note to add this to the docs/readme |
I'm trying to integrate django-cotton into a mature project, and I'm running into issues when default vars not being used during pytest runs.
Templates
cotton/button.html
:index.html
:Issue
When running the app, the component renders with
type="button"
as expected. However, running pytest, I get:I've tried this on a simpler project (cloned the Mozilla Library Tutorial), and it works as expected, so it's my project. The challenge is that I'm not strong with the templating system, so any guidance on where to look would be great.
I appreciate any help and/or guidance!
Extra Info
Settings
Happy to provide more if helpful.
pytest Stack Track
The text was updated successfully, but these errors were encountered: