Skip to content

[MRG] Make test execution on CI possible through py.test command.#433

Merged
lesteve merged 14 commits intojoblib:masterfrom
kdexd:rewrite-pytest-failing-tests
Dec 7, 2016
Merged

[MRG] Make test execution on CI possible through py.test command.#433
lesteve merged 14 commits intojoblib:masterfrom
kdexd:rewrite-pytest-failing-tests

Conversation

@kdexd
Copy link
Copy Markdown

@kdexd kdexd commented Nov 30, 2016

Checkpoint PR for #411 ( Succeeding PR #430 )

  • This PR makes it possible to run tests through py.test command instead of nosetests on both Appveyor and Travis CI. Suitable changes have been made in config files of both CIs as well as the Makefile.
  • Three tests in test_parallel.py failed ( #411 (comment) ) as pytest doesn't intend to support yield based 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.test command. Hence we hit a safe hard bottom that our migration won't break beneath this. Although current tests are written by keeping the nosetests flavor 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 pytest in its own way. Certain decorators can be registered as pytest markers.

  • Parametrize all yield based 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 from joblib.testing...

Work left in this PR:

  • The command python setup.py test still runs tests with nosetests. Need to replace it.
  • how to run doctests with py.test (seems like they are not run at the moment) and make sure that doctests in doc .rst files are run as well.
  • run git grep nose, to see whether there is any lingering nose stuff.

@lesteve
Copy link
Copy Markdown
Member

lesteve commented Nov 30, 2016

[This section will be removed after I complete this task and edit the PR description].

Do you know you can use task lists in Github Flavored Markdown: https://github.com/blog/1375-task-lists-in-gfm-issues-pulls-comments?

Copy link
Copy Markdown
Member

@lesteve lesteve left a comment

Choose a reason for hiding this comment

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

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"
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Any particular reason why you want to test with different py.test versions?

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

pytest 2.9.1 didn't go well with Python 2.6. I'll report back after some experimenting.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

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"
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Is the --disable-pytest-warnings needed/recommended on Windows?

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

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.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Now that you have it in setup.cfg do you need it here?

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

Right, not needed here. Removing.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

--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
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Remove nose

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Still valid.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Actually my bad, we need that because we still have a nose dependency.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

It's so frustrating: nose is only needed for the with_setup. We need to find a way around this.

numpy==1.9.2
nose
wheel
pytest==3.0.4
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

I would say, just use the latest one i.e. without version number

# - for numpy, NUMPY_VERSION is used
# - for scikit-learn, SCIKIT_LEARN_VERSION is used
TO_INSTALL_ALWAYS="pip nose"
TO_INSTALL_ALWAYS="pip nose "
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

You can remove nose here.

TO_INSTALL_ALWAYS="pip nose "
REQUIREMENTS="$TO_INSTALL_ALWAYS"
TO_INSTALL_MAYBE="python numpy flake8"
TO_INSTALL_MAYBE="pytest python numpy flake8"
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Same question as above about why you need to try different pytest versions.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

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.

Test my automatically generate exceptions
"""
from joblib import my_exceptions
from _pytest.assertion.util import BuiltinAssertionError
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Are all these changes really needed?

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

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.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

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?

Copy link
Copy Markdown
Author

@kdexd kdexd Dec 1, 2016

Choose a reason for hiding this comment

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

@lesteve I fixed it just to make sure it doesn;t happen anywhere else. This happens on my machine:

image

I came to know by this that pytest has its own variant of AssertionError.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

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.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

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)
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

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.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

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.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

I've rebased the branch, thanks!

[bdist_rpm]
doc-files = doc

[nosetests]
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

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.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

Oh okay, I have restored this back.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

What I meant (just in case it wasn't clear): you need to figure out how to generate a coverage report with py.test.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

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.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

Yes, @lesteve I don't mind the noise anyways.. Actually I am enjoying this discussion for getting the PR merged. 🍀

@kdexd kdexd force-pushed the rewrite-pytest-failing-tests branch 3 times, most recently from b89f864 to 81e4322 Compare December 1, 2016 09:03
@kdexd
Copy link
Copy Markdown
Author

kdexd commented Dec 1, 2016

@lesteve: nose still has to remain as a requirement due to its with_setup functionality (just this one !). pytest does not have such mechanism, it has markers, so it needs a change in design pattern of certain decorators. I guess I will be completely removing nose in the last PR. Right now I am making sure that tests run uniformly with one suitable version of pytest locally as well as on both CIs. I am afraid if I even try to touch that, how much this whole diff would get confusing 😅 I hope it is okay.

I will try to enable doctests and shift coveralls through pytest though.

Do you know you can use task lists in Github Flavored Markdown

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
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Why is this necessary?

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

Strange, I don't remember writing this line. I'll revert this back.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

Oh okay, this section existed below. It just got reordered when I restored [nosetests] section back.

@kdexd kdexd force-pushed the rewrite-pytest-failing-tests branch from bf9fe4f to 45a818d Compare December 1, 2016 12:40
--cov="joblib"
--disable-pytest-warnings
--doctest-glob="*.rst"
--doctest-modules
Copy link
Copy Markdown
Member

@lesteve lesteve Dec 1, 2016

Choose a reason for hiding this comment

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

Is there an equivalent of doctest-fixtures from nosetests? AFAIR this is something that gets executed before the .rst doctest are run.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

Well there should be, I'll check it out..

@kdexd kdexd force-pushed the rewrite-pytest-failing-tests branch 10 times, most recently from 9408639 to 48457c4 Compare December 1, 2016 16:35
@kdexd
Copy link
Copy Markdown
Author

kdexd commented Dec 1, 2016

@lesteve I am not sure why this one test fails in multiprocessing enabled mode...

@lesteve
Copy link
Copy Markdown
Member

lesteve commented Dec 1, 2016

@lesteve I am not sure why this one test fails in multiprocessing enabled mode...

Hmmm not sure, maybe related to #413. I'll restart the build to see whether it goes away.

@lesteve
Copy link
Copy Markdown
Member

lesteve commented Dec 1, 2016

@lesteve I am not sure why this one test fails in multiprocessing enabled mode...

Hmmm not sure, maybe related to #413. I'll restart the build to see whether it goes away.

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.

@kdexd kdexd force-pushed the rewrite-pytest-failing-tests branch 6 times, most recently from 5a201c7 to aac94d0 Compare December 2, 2016 04:45
@kdexd
Copy link
Copy Markdown
Author

kdexd commented Dec 2, 2016

Hi @lesteve: I have done all the needful work required in this PR. I guess only the CI has to be made green, and work on any review comments you make.. Appveyor is failing on python setup.py bdist_wheel which looks strange to me, and Travis CI passes on all jobs except that one. (#413)

@kdexd kdexd force-pushed the rewrite-pytest-failing-tests branch from aac94d0 to 8a31b2b Compare December 2, 2016 07:18
@lesteve lesteve force-pushed the rewrite-pytest-failing-tests branch 2 times, most recently from 2c5aa88 to b68e69e Compare December 6, 2016 18:22
@lesteve
Copy link
Copy Markdown
Member

lesteve commented Dec 6, 2016

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?

@kdexd kdexd force-pushed the rewrite-pytest-failing-tests branch from b68e69e to 78b61eb Compare December 7, 2016 03:02
@kdexd
Copy link
Copy Markdown
Author

kdexd commented Dec 7, 2016

Hi @lesteve:
The commit ordering at the end was a little bit interchanged so I rebased locally once more, I was hoping that triggering a fresh build would do the needful, as in the earlier case, adding pytest-cov dependency and --cov=joblib argument restored back coveralls.

Interestingly I came across this issue and I see people are complaining regularly...

@kdexd
Copy link
Copy Markdown
Author

kdexd commented Dec 7, 2016

@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

image

Apparently we won't have to worry !

@kdexd
Copy link
Copy Markdown
Author

kdexd commented Dec 7, 2016

Oh, just when I was typing the previous comment, Coveralls passed ! 🎉

@kdexd
Copy link
Copy Markdown
Author

kdexd commented Dec 7, 2016

@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. 😄

@lesteve
Copy link
Copy Markdown
Member

lesteve commented Dec 7, 2016

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.

@lesteve lesteve merged commit 10c7639 into joblib:master Dec 7, 2016
@lesteve
Copy link
Copy Markdown
Member

lesteve commented Dec 7, 2016

Great stuff @karandesai-96, keep up the good work!

@kdexd kdexd deleted the rewrite-pytest-failing-tests branch December 7, 2016 07:45
yarikoptic added a commit to yarikoptic/joblib that referenced this pull request Dec 8, 2016
* 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)
  ...
yarikoptic added a commit to yarikoptic/joblib that referenced this pull request Dec 8, 2016
* 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)
  ...
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