-
Notifications
You must be signed in to change notification settings - Fork 694
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
Port lib/test_util.py to pytest #1413
Conversation
Looks like the original |
@@ -21,6 +21,8 @@ | |||
# | |||
from __future__ import absolute_import, division | |||
|
|||
from unittest import TestCase |
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.
Is using unittest
really necessary? I thought we can get rid of it. pytest
supports setup_method()/teardown_method()
(instead of setUp()
) https://docs.pytest.org/en/2.7.3/xunit_setup.html
(I know that it also supports running UnitTest
classes.)
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 missed that somehow! I'll read more about this and try to get rid of unittest
. Thanks!
Why us Travis complaining
|
.travis.yml
Outdated
- SETUP_CMD="" | ||
- BUILD_CMD="pip install -v package/ && pip install testsuite/" | ||
- CONDA_DEPENDENCIES="mmtf-python nose=1.3.7 mock six biopython networkx cython joblib nose-timer" | ||
- CONDA_ALL_DEPENDENCIES="mmtf-python nose=1.3.7 mock six biopython networkx cython joblib nose-timer matplotlib netcdf4 scikit-learn scipy seaborn coveralls clustalw=2.1" | ||
# Install griddataformats from PIP so that scipy is only installed in the full build (#1147) | ||
- PIP_DEPENDENCIES='griddataformats' | ||
- PIP_DEPENDENCIES='griddataformats pytest pytest-cov' |
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.
please add them do conda. They are both available on the conda-forge channel. This might also be messing up your pytest installation. But I'm not sure about that.
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 would still prefer pytest as a conda dependency.
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.
@kain88-de Should I add them to CONDA _DEPENDENCIES
or CONDA_ALL_DEPENDENCIES
?
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.
you need to add them to both. We can check in another PR why they aren't installed automatically.
@@ -124,7 +126,7 @@ def test_strings(self): | |||
assert_equal(util.iterable(u"unicode string"), False) | |||
|
|||
|
|||
class TestFilename(object): | |||
class TestFilename(TestCase): |
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.
You are using TestCase
here to make the test classes discoverable to pytest. This means this class isn't normally picked up by pytest. Please make sure the class has no init method. You can also run pytest with --collect-only
to make sure all tests are picked up quickly.
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.
No, I'm using it because only classes that inherit from TestCase
get their setUp
and tearDown
methods executed.
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.
So we need this for a swift conversion and then remove it one by one again later. check
I have flipped the MAIN_CMD command so that |
@utkbansal if you could remove the yield based test that would be great. They do generate quite a lot of noise in the output. |
We have a lot of |
Suppressing the warnings for now is fine. |
Wohoo! Coverage increased! 😬 |
And the full test build is passing (likely by chance, but still!). |
- CONDA_DEPENDENCIES="mmtf-python nose=1.3.7 mock six biopython networkx cython joblib nose-timer" | ||
- CONDA_ALL_DEPENDENCIES="mmtf-python nose=1.3.7 mock six biopython networkx cython joblib nose-timer matplotlib netcdf4 scikit-learn scipy seaborn coveralls clustalw=2.1" | ||
- CONDA_DEPENDENCIES="mmtf-python nose=1.3.7 mock six biopython networkx cython joblib nose-timer pytest=3.1.2 pytest-cov=2.5.1" | ||
- CONDA_ALL_DEPENDENCIES="mmtf-python nose=1.3.7 mock six biopython networkx cython joblib nose-timer matplotlib netcdf4 scikit-learn scipy seaborn coveralls clustalw=2.1 pytest=3.1.2 pytest-cov=2.5.1" |
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 the version pinning?
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.
Conda already says that it has pytest installed and still it did not work. Also, the version it has is 2.7, so there has been a major release after that.
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.
should be able to do conda upgrade pytest
?
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.
@richardjgowers after the source ci-helpers/travis/setup_conda.sh
step?
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.
the older version comes from astropy. They specifically install an older version of pytest for themselves. Leave the pinning for now. I'm asking what they use as a preferred way to use a newer pytest version.
Should be ready to merge, only the full build times out. We might not need the full build to succeed for the last commit as it was only shifting requirements from pip to conda and the commit previous to this verifies that coverage works and has not dropped. |
@utkbansal awesome, one module down! Can you try and get the unfinished coordinates port PR up ASAP so we can see what changes are required. |
Fixes partially #884
Changes made in this Pull Request:
PR Checklist