Skip to content

Comments

[MRG] DOC: Add pytest version in documentation#12002

Merged
rth merged 7 commits intoscikit-learn:masterfrom
wdevazelhes:doc/add_pytest_version
Sep 6, 2018
Merged

[MRG] DOC: Add pytest version in documentation#12002
rth merged 7 commits intoscikit-learn:masterfrom
wdevazelhes:doc/add_pytest_version

Conversation

@wdevazelhes
Copy link
Contributor

This PR adds the minimal pytest version needed in order to avoid arguments like match (as in with pytest.raises(SomeError, match='some error message'):) to fail silently (see #12001)

README.rst Outdated
After installation, you can launch the test suite from outside the
source directory (you will need to have the ``pytest`` package installed)::
source directory (you will need to have the ``pytest`` package installed
(version >= 3.3.0))::
Copy link
Member

Choose a reason for hiding this comment

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

maybe "you will need to have pytest >= 3.3 installed"

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done

<https://docs.pytest.org>`_ library. Some tests also require having
`pandas <https://pandas.pydata.org/>` installed.
<https://docs.pytest.org>`_ library (version >= 3.3.0). Some tests also require
having `pandas <https://pandas.pydata.org/>` installed.
Copy link
Member

Choose a reason for hiding this comment

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

Maybe

"Testing requires having pytest <https://docs.pytest.org>_ >= 3.3.0."

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done

Copy link
Member

@rth rth left a comment

Choose a reason for hiding this comment

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

Thanks !

@jnothman
Copy link
Member

jnothman commented Sep 4, 2018

Can we assert this programmatically in conftest.py?

@wdevazelhes
Copy link
Contributor Author

Can we assert this programmatically in conftest.py?

something like this ?

--- a/conftest.py
+++ b/conftest.py
@@ -12,6 +12,10 @@ import pytest
 from _pytest.doctest import DoctestItem
 
 
+if LooseVersion(pytest.__version__) < '3.3.0':
+    raise('Your version of pytest is too old, you should have at least '
+          'pytest >= 3.3.0 installed.')
+
 def pytest_collection_modifyitems(config, items):
 
     # FeatureHasher is not compatible with PyPy

@jnothman
Copy link
Member

jnothman commented Sep 5, 2018 via email

@wdevazelhes
Copy link
Contributor Author

In any case as the CI version is up to date, I think false negatives would be detected before merging, but I guess this would indeed help contributors to avoid them before committing, when running test locally

conftest.py Outdated
from _pytest.doctest import DoctestItem


if LooseVersion(pytest.__version__) < '3.3.0':
Copy link
Member

Choose a reason for hiding this comment

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

Make the min version a variable for a little future proofing

@wdevazelhes
Copy link
Contributor Author

Make the min version a variable for a little future proofing

I tried to do this so as to only have to change it in README.rst and in doc/conftest.py, taking inspiration from your PR #11734 (I didn't manage to use the variable in the README.rst)

If this is too much I can revert and only change conftest.py to use a variable name

If it is good I can also maybe try to do it for other version numbers in the project in another PR ?
Like putting all minimal versions substitutions in a file so that even in the README.rst it is updated (by importing this file at the beginning) ?

doc/conf.py Outdated
# loading variables
conftest_vars = {}
with open(os.path.join('..', 'conftest.py')) as fp:
exec(fp.read(), conftest_vars)
Copy link
Member

Choose a reason for hiding this comment

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

Not so keen on the exec, and avoiding the exec would probably lead to some possibly awkward imports / PATH issues.

Having this mechanism to avoid putting the version once in a rst is a bit too much IMO :) If the version changes we would have to change the readme anyway, so we might as well do it twice (which would need to be done twice in any case) . git grep 3.3.0 doesn't cost much..

Copy link
Member

Choose a reason for hiding this comment

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

Better off having a sklearn/_requirements.py file than this... but this is all too much sophistication for the present PR. Thanks for trying to makde it maintainable!

@wdevazelhes
Copy link
Contributor Author

I agree it was too much, I simplified the PR

@rth rth merged commit b4bf033 into scikit-learn:master Sep 6, 2018
@wdevazelhes wdevazelhes deleted the doc/add_pytest_version branch September 6, 2018 09:47
jnothman pushed a commit to jnothman/scikit-learn that referenced this pull request Sep 6, 2018
jnothman pushed a commit to jnothman/scikit-learn that referenced this pull request Sep 17, 2018
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.

3 participants