Skip to content
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

Use pytest to parametrize some of the tests. #232

Merged
merged 1 commit into from
Jun 6, 2020

Conversation

Carreau
Copy link
Contributor

@Carreau Carreau commented May 20, 2020

This basically move the looping on multiple conditions from being the
test responsibility to being pytest's it has several advantages.

  1. I find it make the test more redable as you only have to focus on
    what you want to test.

  2. In case of test failures it will have more informative message with
    which sub-condition fails and will not stop on the first error,
    usually allowing to narrow down the error case faster.

  3. It allow to run a single subtest when fixing code (using the --lf, or
    --ff pytest flags).

  4. Show which subcase are slow with --durations=..., and could integrade
    with multi-worker testing or randomisations.

It does have minimal drawbacks; but this does increase some of the setup
time which is now done sometime for each case instead of one per group.

use_threads seem to be used a lot, so I made it a module-scoped fixture,
a function only have to use the parameter use_threads to automatically
been generic over some parameters, other are ad-hoc.

I did not parametrize on everything as I mostly want to test if you are
ok with this approach.

This was initially push by trying to test current decode_partial in
blosc which is still in progress and was failing on a subset of cases.


GitHub note, the diff will me messy if you don't "ignore whitespace", most of the changes are de-indent and removal of for loops.

TODO:

  • Unit tests and/or doctests in docstrings
  • tox -e py38 passes locally
  • Docstrings and API docs for any new/modified user-facing classes and functions
  • Changes documented in docs/release.rst
  • tox -e docs passes locally
  • AppVeyor and Travis CI passes
  • Test coverage to 100% (Coveralls passes)

@pep8speaks
Copy link

pep8speaks commented May 20, 2020

Hello @Carreau! Thanks for updating this PR. We checked the lines you've touched for PEP 8 issues, and found:

There are currently no PEP 8 issues detected in this Pull Request. Cheers! 🍻

Comment last updated at 2020-05-26 16:38:31 UTC

@Carreau Carreau force-pushed the pytest-param branch 3 times, most recently from edff8b7 to 8412d2a Compare May 21, 2020 03:20
@Carreau
Copy link
Contributor Author

Carreau commented May 21, 2020

I'm slightly confised the test show as still pending but are actually passing.

@Carreau
Copy link
Contributor Author

Carreau commented May 22, 2020

closing and reopening to kick the tests.

@Carreau Carreau closed this May 22, 2020
@Carreau Carreau reopened this May 22, 2020
This basically move the looping on multiple conditions from being the
test responsibility to being pytest's it has several advantages.

1) I find it make the test more redable as you only have to focus on
   what you want to test.

2) In case of test failures it will have more informative message with
   which sub-condition fails and will not stop on the first error,
   usually allowing to narrow down the error case faster.

3) It allow to run a single subtest when fixing code (using the --lf, or
   --ff pytest flags).

4) Show which subcase are slow with --durations=..., and could integrade
   with multi-worker testing or randomisations.

It does have minimal drawbacks; but this does increase some of the setup
time which is now done sometime for each case instead of one per group.

use_threads seem to be used a lot, so I made it a module-scoped fixture,
a function only have to use the parameter use_threads to automatically
been generic over some parameters, other are ad-hoc.

I did not parametrize on everything as I mostly want to test if you are
ok with this approach.

This was initially push by trying to test current decode_partial in
blosc which is still in progress and was failing on a subset of cases.
@Carreau
Copy link
Contributor Author

Carreau commented May 26, 2020

rebased.

Copy link
Member

@jrbourbeau jrbourbeau left a comment

Choose a reason for hiding this comment

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

Thanks for this @Carreau! Apologies for the delayed response, everything here looks great

@jrbourbeau jrbourbeau merged commit d7765f5 into zarr-developers:master Jun 6, 2020
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.

None yet

3 participants