-
Notifications
You must be signed in to change notification settings - Fork 2.6k
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
Switch to pytest and tox #1763
Switch to pytest and tox #1763
Conversation
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.
Thanks for this. I'm all for making our tests runnable from tox
and pytest
, but not enforcing the use of pytest
in our CI. What I'm not a big fan of is pytest's magic and overloading of standard python functionality (e.g. assert) and that it's now another dependency to black to test. But I'll live with it if other black core devs like pytest, I've had to learn it and deal with it for other projects.
Aside from this, love the refactor and split of blackd tests. Love the clearer deps now too.
python -m pip install --upgrade pip | ||
python -m pip install --upgrade coverage | ||
python -m pip install --upgrade hypothesmith | ||
python -m pip install -e ".[d]" | ||
python -m pip install --upgrade tox |
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.
Why not install together?
python -m pip install --upgrade pip tox
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.
Maybe the newest pip has something new and exciting, and we want to use the new and exciting pip for the other stuff?
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.
Just seems a waste of an extra fork/exec for now ... If we hit a bug then I'd change back to the two executes ... Not a big deal, thus why I didn't request changes ...
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'm with @hugovk on this.
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.
If it were a single call to pip, then there's no point upgrading pip (unless it is cached for next time, and it's not).
A concrete reason:
For Python 3.8 on Windows, pip 19.3+ is needed to install wheels (at least for Pillow). We've added the double command to the installation instructions, and that came up again this week.
This isn't specifically needed for Black test right now, but I suggest skipping the pip upgrade altogether and using the CI image's version, or having two calls.
(Right now, pip in the image is the latest version, so the call is really quick; and it's pretty quick for an upgrade as well.)
python -m pip install --upgrade pip | ||
python -m pip install --upgrade coverage | ||
python -m pip install -e ".[d]" | ||
python -m pip install --upgrade tox |
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.
Same - Install both?
I'm not in love with the idea of Pytest, but I have a great experience with it in all of my repositories. If I cannot use |
Yes, let's definitely do the test conversions in a separate PR.
I just want to state I'm not blocking pytest, but sharing I'm not for it. Mainly due to how much long, due to it's |
While on the topic of
The main downside is that Black incompatibilities with newer versions of modules / packages won't be automatically discovered since we'll be pinning to probably older versions. Using PyUp or other services mostly mitigates this issue though. Just some ideas to think about. |
If you do the PRs I'm sure we'll merge them :) ... I love PyUp method, but I always like to have both a pinned and unpinned options. This is due to having situations where I've had to fork to unpin to install things in some environments. And I've not wanted to inflict that pain on users of libraries I've maintained. |
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.
This is an improvement to allow for Devs to get a CI like env easier. Lets merge it.
No one has spoke up about not liking this. I'm merging. |
-r{toxinidir}/test_requirements.txt | ||
hypothesmith | ||
lark-parser < 0.10.0 | ||
; lark-parser's version is set due to a bug in hypothesis. Once it solved, that would be fixed. |
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.
@saroad2 It looks like lark-parser
's been updated in the test dependencies for hypothesmith
- could/should we remove this version pin?
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 guess we should :) I added this pinning so the tests would pass.
* Add venv to .gitignore * Use tox to run tests * Make fuzz run in tox * Split tests files * Fix import error
Hi @saroad2, thanks for moving us to pytest, it's been a better experience personally. Anyway I'm working on removing parameterized as a test suite dependency and I noticed pytest-mock + pytest-cases. I'm not familiar with these plugins and AFAICT the test suite doesn't use these plugins ATM. If that's the case I'd wish to remove them. Why were they added? Thank you in advance! |
Hey @ichard26, I think I added them by mistake. However, if you take a close look at pytest-cases, I think you'll find it as a very helpful plugin to pytest. |
It became a good practice in python to use Tox. In that way we can make sure that the contributors of black test in the same environment as the CI process.
Moreover, I propose moving to use Pytest as the testing infrastructure because it could make our tests much clearer. Consider the following tests from test_black.py:
Those are practically the same test. Why do we need to write it twice? with pytest we could simply write:
I think both changes will be beneficial for Black.
What do you think?