12rambau / pytest-copie

The pytest plugin for your copier templates 📒
https://pytest-copie.readthedocs.io/en/latest/
MIT License
15 stars 5 forks source link

Pytest-copie don't use the HEAD version if vcs-ref exist #71

Closed 12rambau closed 8 months ago

12rambau commented 8 months ago

I have a templlate that is introducing a bug in the resolution and I realized that the test are still run on this published version instead of the one stored in the local files.

It's related to this issue: https://github.com/copier-org/copier/issues/1484 in the main copier but I don't manage to enforce/test this behaviour here.

I thought naively that https://github.com/12rambau/pytest-copie/pull/70 was sufficient but it's not.

drewoldag commented 8 months ago

Hi there, I'm currently experimenting with pytest-copie and so far I'm really liking it. I would like to write some unit tests with pytest-copie and have those exercised automatically using pre-commit. However, given that the template that I'm apply this to already has several tagged releases, I'm not sure how to go about checking the current state of the template with the tests instead of the latest tag.

When I test manually I used copier copy --vcs-ref=HEAD <local directory> <output directory>, with the assumption that I've locally committed the template changes that I'm manually testing.

Is there a recommended way to specify --vcs-ref=HEAD for unit tests that use pytest-copie? Additionally, do you happen to know if it's always necessary to have locally committed changes in order to for the newest template to be used by copier - if the changes have to be locally committed, then I suppose I need to use the post-commit stage setting in pre-commit...

12rambau commented 8 months ago

Hi I'm not very familiar with running tests within pre-commits specifically because I agree with most of the arguments present on this thread. I usually prefer to run tests outside using tox or nox and include them in my CI. I'm not telling you to stop, I simply specify that I will be useless on the pre-commit part of your question.

On the vcs-ref at the moment I'm lost myself and I wanted to have a look this WE, I don't understand why my fix in #70 is not sufficient to enforce use of current version of the template.

12rambau commented 8 months ago

@drewoldag the solution was dead simple.... release a new version....

The modification I made in #70 was indeed the way to go. I've tested it in my python package template and it worked as expected.

drewoldag commented 8 months ago

Awesome, thanks for the updated release too!