Skip to content

TST: display reason of skipping by default with pytest #10946

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

Merged

Conversation

jorisvandenbossche
Copy link
Member

Reference Issues/PRs

See discussion in #10835 (comment)
Actually doing this change, will make it easier to see how it looks on Travis to decide if this is too verbose or not.

With this change, pytest will show the reason that a test is skipped by default. This can be especially useful to not be surprised why your doctests are skipping because you don't have numpy 1.14.

@lesteve
Copy link
Member

lesteve commented Apr 10, 2018

You need to figure out why the Python 3.4 is failing. No suggestions off the top of my head I am afraid ...

About 20 lines in the Python 3.6 build (with numpy >= 1.14)
https://travis-ci.org/scikit-learn/scikit-learn/jobs/364572375#L2844

About 100 lines in the Python 2.7 build (with numpy < 1.14)
https://travis-ci.org/scikit-learn/scikit-learn/jobs/364572373#L3044

I am fine with merging this. It is useful in the numpy >= 1.14 case to avoid suprises. You could also argue it is useful in general to be reminded about skipped tests that we may want to fix at one point.

@jorisvandenbossche
Copy link
Member Author

Hmm, one thing I can think of that the failing build seems to use a much older version of pytest (3.0.5 vs 3.5.0). I think the reason for this is that conda does not have recent packages anymore for Python 3.4 (both main channel as conda-forge).

@@ -61,6 +61,8 @@ if [[ "$DISTRIB" == "conda" ]]; then

conda create -n testenv --yes $TO_INSTALL
source activate testenv
conda install pip --yes
Copy link
Member

@lesteve lesteve Apr 10, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  • pip is installed in any conda environment (at least by default) so you don't need this line
  • can you only install pytest if $PYTHON_VERSION == "3.4" so that we can drop this special case once we stop supporting Python 3.4?
  • can you use pip install --upgrade --no-deps pytest. Just a bit paranoid with pip install -U that upgrades all the dependencies ...

Copy link
Member Author

@jorisvandenbossche jorisvandenbossche Apr 10, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, I was planning to do those things, just wanted to make sure it was actually fixing it before diving putting time in it :-)

Will clean up now

@@ -62,6 +62,11 @@ if [[ "$DISTRIB" == "conda" ]]; then
conda create -n testenv --yes $TO_INSTALL
source activate testenv

# for python 3.4, conda does not have recent pytest packages
if [[ "$PYTHON_VERSION" == "3.4" ]]; then
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If it's possible to use another conda channel, that might be better than overwriting a conda install with pip

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's not in defaults, and not in conda-forge, and from a quick search on anaconda.org it does not seem they have their own channel

setup.cfg Outdated
@@ -7,6 +7,7 @@ test = pytest
addopts =
--doctest-modules
--disable-pytest-warnings
-r s
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could we please use the long form options?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I changed 's' to 'skipped' (that apparently works), but for "-r" I don't see any long format in the pytest help

@jnothman
Copy link
Member

I'll take your word on -r.
LGTM

@@ -62,6 +62,11 @@ if [[ "$DISTRIB" == "conda" ]]; then
conda create -n testenv --yes $TO_INSTALL
source activate testenv

# for python 3.4, conda does not have recent pytest packages
if [[ "$PYTHON_VERSION" == "3.4" ]]; then
pip install --upgrade --no-deps pytest
Copy link
Member

@lesteve lesteve Apr 11, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If I had to guess how to quickly fix the error, I would do pip install pytest==3.5.

I guess I was a bit naive about pip install --upgrade --no-deps. It probably does not install dependencies and I was hoping it would only avoid upgrading the dependencies.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Or if six is the only missing dependency, install that as well.

But actually, somewhat below we also do pip install coverage codecov, so maybe we don't need to care to much about not installing dependencies with pip?

@lesteve
Copy link
Member

lesteve commented Apr 11, 2018

Travis passes, I am going to merge this one. Thanks @jorisvandenbossche for making the world a slightly less surprising place ;-).

@lesteve lesteve merged commit 312f640 into scikit-learn:master Apr 11, 2018
@jorisvandenbossche jorisvandenbossche deleted the pytest-show-skip-reason branch April 11, 2018 09:03
@jorisvandenbossche
Copy link
Member Author

Thanks!

@rth
Copy link
Member

rth commented Apr 22, 2018

I think this should have been -r s as in earlier commits not -r skipped as the latest version,

$ pytest --help
[...]
  -r chars              show extra test summary info as specified by chars
                        (f)ailed, (E)error, (s)skipped, (x)failed, (X)passed,
                        (p)passed, (P)passed with output, (a)all except pP.
                        Warnings are displayed at all times except when
                        --disable-warnings is set

currently passing tests are also included in the test summary in the end
(since ("p" in "skipped") is True), As a result the failing tracebacks are not and the end of the CI log but somewhere in the middle, which is hard to find for contributors.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants