[MRG] Make test execution on CI possible through py.test command.#433
[MRG] Make test execution on CI possible through py.test command.#433lesteve merged 14 commits intojoblib:masterfrom
Conversation
Do you know you can use task lists in Github Flavored Markdown: https://github.com/blog/1375-task-lists-in-gfm-issues-pulls-comments? |
lesteve
left a comment
There was a problem hiding this comment.
I know it is a WIP, but still a few comments.
.travis.yml
Outdated
| - PYTHON_VERSION="2.7" NUMPY_VERSION="1.7" | ||
| - PYTHON_VERSION="3.3" NUMPY_VERSION="1.8" | ||
| - PYTHON_VERSION="3.4" NUMPY_VERSION="1.9" | ||
| - PYTHON_VERSION="2.6" NUMPY_VERSION="1.6" PYTEST_VERSION="2.6.3" |
There was a problem hiding this comment.
Any particular reason why you want to test with different py.test versions?
There was a problem hiding this comment.
pytest 2.9.1 didn't go well with Python 2.6. I'll report back after some experimenting.
There was a problem hiding this comment.
I see that you have reverted your changes, but don't worry about Python 2.6 we are going to drop support for it pretty soon.
appveyor.yml
Outdated
| # installed library. | ||
| - "cd C:\\" | ||
| - "python -c \"import nose; nose.main()\" -v -s joblib" | ||
| - "py.test --disable-pytest-warnings --pyargs joblib" |
There was a problem hiding this comment.
Is the --disable-pytest-warnings needed/recommended on Windows?
There was a problem hiding this comment.
pytest > 3.0.0 raises more than 300 pytest warnings as yield based tests have been officially deprecated. Since they're expected to arise, and a long list messes up the CI log, I have disable them for a while, now from both Windows and Linux. I'll remove this once I parametrize yield based tests in subsequent PRs.
There was a problem hiding this comment.
Now that you have it in setup.cfg do you need it here?
There was a problem hiding this comment.
--disable-pytest-warnings flag is not available in older pytest versions. For python 2.7,, installing pytest without version specified installs 2.7.2. As the pytest warnings are anyhow going to be cleared out later, I'm not adding this right now. We'll think of enforcing a version > 2.8 once Python 2.6 support is dropped...
| @@ -4,3 +4,4 @@ | |||
| numpy==1.9.2 | |||
| nose | |||
There was a problem hiding this comment.
Actually my bad, we need that because we still have a nose dependency.
There was a problem hiding this comment.
It's so frustrating: nose is only needed for the with_setup. We need to find a way around this.
appveyor/requirements.txt
Outdated
| numpy==1.9.2 | ||
| nose | ||
| wheel | ||
| pytest==3.0.4 |
There was a problem hiding this comment.
I would say, just use the latest one i.e. without version number
continuous_integration/install.sh
Outdated
| # - for numpy, NUMPY_VERSION is used | ||
| # - for scikit-learn, SCIKIT_LEARN_VERSION is used | ||
| TO_INSTALL_ALWAYS="pip nose" | ||
| TO_INSTALL_ALWAYS="pip nose " |
continuous_integration/install.sh
Outdated
| TO_INSTALL_ALWAYS="pip nose " | ||
| REQUIREMENTS="$TO_INSTALL_ALWAYS" | ||
| TO_INSTALL_MAYBE="python numpy flake8" | ||
| TO_INSTALL_MAYBE="pytest python numpy flake8" |
There was a problem hiding this comment.
Same question as above about why you need to try different pytest versions.
There was a problem hiding this comment.
I don't know the CI was unhappy initially. Once it became green, I opened a PR fr further discussions. Although I am still trying to settle at a proper version.
joblib/test/test_my_exceptions.py
Outdated
| Test my automatically generate exceptions | ||
| """ | ||
| from joblib import my_exceptions | ||
| from _pytest.assertion.util import BuiltinAssertionError |
There was a problem hiding this comment.
Are all these changes really needed?
There was a problem hiding this comment.
Yes, it raised an AssertionError as JoblibAssertionError is not an instance of _pytest.assertion.util.AssertionError. While running the test with pytest, we have to reference the original AssertionError shipped by core python like this.
There was a problem hiding this comment.
I don't get any error while running joblib/test/test_my_exceptions.py in master so I don't get why this is needed. Maybe it is needed for a specific OS + python version + pytest version combination?
There was a problem hiding this comment.
@lesteve I fixed it just to make sure it doesn;t happen anywhere else. This happens on my machine:
I came to know by this that pytest has its own variant of AssertionError.
There was a problem hiding this comment.
OK this happens for Python 2.7 fair enough. To be honest, I would say just make the test simpler by just using another kind of exception for example ImportError.
There was a problem hiding this comment.
Oh okay. I thought AssertionError as a testcase must be existing due to some corner case.
| yield check_backend_context_manager, test_backend | ||
| # TODO: parametrize this block later | ||
| # yield check_backend_context_manager, test_backend | ||
| check_backend_context_manager(test_backend) |
There was a problem hiding this comment.
OK so this is the actual fix for the tests failing with py.test in master. No clue why this yield does not work but the other yield does not seem to cause any issue.
There was a problem hiding this comment.
I pushed this fix in master so we can already start using py.test locally. The downside is that you need to rebase on master to fix the conflict.
| [bdist_rpm] | ||
| doc-files = doc | ||
|
|
||
| [nosetests] |
There was a problem hiding this comment.
nose was use for coverage you can not remove this like this. This is probably why the coveralls status is shown as waiting for result.
Also it would be good to make sure that doctests are tested.
There was a problem hiding this comment.
Oh okay, I have restored this back.
There was a problem hiding this comment.
What I meant (just in case it wasn't clear): you need to figure out how to generate a coverage report with py.test.
There was a problem hiding this comment.
Sorry for the noise, I see you have done something like this. The end goal would be to make sure we have some coverall status in this PR.
There was a problem hiding this comment.
Yes, @lesteve I don't mind the noise anyways.. Actually I am enjoying this discussion for getting the PR merged. 🍀
b89f864 to
81e4322
Compare
|
@lesteve: I will try to enable doctests and shift coveralls through pytest though.
I used it in the issue comment, so funny why didn't this strike me right now! I'll go forward and amend the description, thanks ! [EDIT]: I read the modified description after writing this comment, thanks for editing the description for me ! |
| doc-files = doc | ||
|
|
||
| [wheel] | ||
| universal=1 |
There was a problem hiding this comment.
Strange, I don't remember writing this line. I'll revert this back.
There was a problem hiding this comment.
Oh okay, this section existed below. It just got reordered when I restored [nosetests] section back.
bf9fe4f to
45a818d
Compare
| --cov="joblib" | ||
| --disable-pytest-warnings | ||
| --doctest-glob="*.rst" | ||
| --doctest-modules |
There was a problem hiding this comment.
Is there an equivalent of doctest-fixtures from nosetests? AFAIR this is something that gets executed before the .rst doctest are run.
There was a problem hiding this comment.
Well there should be, I'll check it out..
9408639 to
48457c4
Compare
|
@lesteve I am not sure why this one test fails in multiprocessing enabled mode... |
It seems to be failing consistently. I can not reproduce the failure locally though. Also if you could disable the warnings in setup.cfg as you were doing at one point it would be great. This way the Travis log would be a bit less verbose. |
5a201c7 to
aac94d0
Compare
aac94d0 to
8a31b2b
Compare
2c5aa88 to
b68e69e
Compare
|
Hmm I rebased on master to solve the conflicts and it seems like we lost coveralls in the process. @karandesai-96 I remember it was happening before did you do something specific to get it to work? |
b68e69e to
78b61eb
Compare
|
Hi @lesteve: Interestingly I came across this issue and I see people are complaining regularly... |
|
@lesteve and another issue was opened just 9 hours ago, just around the time when our PR went off on Coveralls: lemurheavy/coveralls-public#892 Apparently we won't have to worry ! |
|
Oh, just when I was typing the previous comment, Coveralls passed ! 🎉 |
|
@GaelVaroquaux I have already made some commits on a separate branch and removed nose completely. The thing is, its diff is comparable to the current PR and this PR comments have grown too much so I have decided to keep that branch separate and make a PR within ten minutes after this one is merged. 😄 |
|
OK great let's merge this one! @GaelVaroquaux trying to separate the work into meaningful chunks in order to ease the migration and the review process. From this PR onwards, you are supposed to run the tests with py.test. nose will be completely removed eventually. |
|
Great stuff @karandesai-96, keep up the good work! |
* commit '0.10.2-55-g660fe5d': (52 commits) MAINT simplify way to skip doctests Do not print frames with IPython internals in format_stack BF(TST): compare for version in pickled filename ignoring full path, and looking for _ as well (joblib#445) [MRG] Remove nose dependency completely. (joblib#441) MAINT add Python 3.5 in setup.py Remove some Python 2.6 specific code [MRG] Make test execution on CI possible through py.test command. (joblib#433) Remove more python 2.6 related code (joblib#440) [MRG] Use commit range for diff in flake8_diff.sh (joblib#439) MAINT remove support for python 2.6 (joblib#437) Improve doc about caching methods (joblib#432) Get the tests passing with py.test MAINT update flake8_diff.sh COSMIT move stdlib imports where they belong [MRG] Replace assert_* methods with "assert" keyword statements. (joblib#430) Reraise when the exception is not a TransportableException (joblib#429) Make sure LICENSE.txt is included in the wheel Add LICENSE.txt Update doc/paralle.rst [MRG+1] Remove all nose imports from test scripts. (joblib#422) ...
* releases: (52 commits) MAINT simplify way to skip doctests Do not print frames with IPython internals in format_stack BF(TST): compare for version in pickled filename ignoring full path, and looking for _ as well (joblib#445) [MRG] Remove nose dependency completely. (joblib#441) MAINT add Python 3.5 in setup.py Remove some Python 2.6 specific code [MRG] Make test execution on CI possible through py.test command. (joblib#433) Remove more python 2.6 related code (joblib#440) [MRG] Use commit range for diff in flake8_diff.sh (joblib#439) MAINT remove support for python 2.6 (joblib#437) Improve doc about caching methods (joblib#432) Get the tests passing with py.test MAINT update flake8_diff.sh COSMIT move stdlib imports where they belong [MRG] Replace assert_* methods with "assert" keyword statements. (joblib#430) Reraise when the exception is not a TransportableException (joblib#429) Make sure LICENSE.txt is included in the wheel Add LICENSE.txt Update doc/paralle.rst [MRG+1] Remove all nose imports from test scripts. (joblib#422) ...


Checkpoint PR for #411 ( Succeeding PR #430 )
py.testcommand instead ofnosetestson both Appveyor and Travis CI. Suitable changes have been made in config files of both CIs as well as the Makefile.pytestdoesn't intend to supportyieldbased tests very well. Those tests now have sequential assertion written within, and a TODO comment is added for parametrization in next phase.Future Roadmap:
By the merge of this PR we reach a checkpoint where the bare minimum setup atleast runs by issuing
py.testcommand. Hence we hit a safe hard bottom that our migration won't break beneath this. Although current tests are written by keeping thenosetestsflavor in mind, and the whole flow can be really simplified by using pytest fixtures, markers and parametrizations.Empty out joblib/test/common.py into two files - joblib/testing.py and joblib/test/conftest.py. Session wide setup/ teardowns if necessary will be included in this file as it is interpreted by
pytestin its own way. Certain decorators can be registered as pytest markers.Parametrize all
yieldbased tests module by module. I will keeping on sequentially opening PRs where I will completely ✨ pytestify ✨ each module. Although the pattern will be same, all imports fromjoblib.testing...Work left in this PR:
python setup.py teststill runs tests withnosetests. Need to replace it.