-
Notifications
You must be signed in to change notification settings - Fork 1
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
Update tests to use copier instead of cookiecutter #13
Conversation
tests/test_values.py
Outdated
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I am not sure we need to test values now, because validators e.g. this force user to provide correct input. Lets discuss this.
@@ -45,7 +45,7 @@ install_requires = | |||
dev = | |||
coverage [toml] | |||
pytest | |||
pytest-cookies | |||
pyprojroot |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I am not familiar with pyprojroot. I was originally thinking of replacing 'pytest-cookies' with 'pytest-copie'. See https://github.com/12rambau/pytest-copie
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
pyprojroot
is a simple but very helpful package to easily refer to paths relative to the project root. For the tests specifically, I used it to guarantee that the source refers to the root of the project, regardless of where the tests are called from (which can sometimes cause issues with these things.)
Using pytest-copie
would be nice, but it doesn't a session-scoped fixture such as the one that pytest-cookies
does. That means we end up with a whole bunch of ScopeMismatch
errors if we do a 'naive' replacement:
ERROR tests/test_project.py::test_pytest - Failed: ScopeMismatch: You tried to access the function scoped fixture copie with a session scoped request object. Requesting fixture stack:
ERROR tests/test_project.py::test_coverage - Failed: ScopeMismatch: You tried to access the function scoped fixture copie with a session scoped request object. Requesting fixture stack:
ERROR tests/test_project.py::test_tox - Failed: ScopeMismatch: You tried to access the function scoped fixture copie with a session scoped request object. Requesting fixture stack:
ERROR tests/test_project.py::test_subpackage - Failed: ScopeMismatch: You tried to access the function scoped fixture copie with a session scoped request object. Requesting fixture stack:
ERROR tests/test_project.py::test_generate_api_docs - Failed: ScopeMismatch: You tried to access the function scoped fixture copie with a session scoped request object. Requesting fixture stack:
ERROR tests/test_project.py::test_coverage_api_docs - Failed: ScopeMismatch: You tried to access the function scoped fixture copie with a session scoped request object. Requesting fixture stack:
ERROR tests/test_project.py::test_doctest_api_docs - Failed: ScopeMismatch: You tried to access the function scoped fixture copie with a session scoped request object. Requesting fixture stack:
ERROR tests/test_project.py::test_ruff_check - Failed: ScopeMismatch: You tried to access the function scoped fixture copie with a session scoped request object. Requesting fixture stack:
ERROR tests/test_project.py::test_bumpversion - Failed: ScopeMismatch: You tried to access the function scoped fixture copie with a session scoped request object. Requesting fixture stack:
Looking at the pytest-cookies
code, it seems like it should be an easy contribution to add a similar session scoped version. We should look into that!
Great work @sjvrijn! Thanks. I have left a few inline comments for us to discuss. I have tested it on my machine and one test has failed... |
This adapts the custom session scoped fixture to manually create a copier copy, since the pytest-copie plugin does not yet support a session-scoped fixture
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It looks great Sander! I will merge it now.
Summary
Updates all tests to remove references to
cookiecutter
or thepytest-cookies
plugin, and makes sure all tests work withcopier
instead. Note that the tests intest_values
only tests for not erroring, and the 'directory name with spaces' test now expects an error since that validation is not (yet) implemented for copier.Fixes #1 (?)
Instructions to review the pull request
Add my fork as a remote and switch to the
1-update-tests
branch (or make a new clone, your choice), then install the required dependencies and run the tests.Note: On my local WSL installation, the
tox
test hangs for some reason, although I suspect this may be a pyenv related issue. I'm assuming/hoping that this will not be a problem in the CI.