8000 Test `pop` with default argument by jakirkham · Pull Request #380 · zarr-developers/zarr-python · GitHub
[go: up one dir, main page]

Skip to content

Test pop with default argument #380

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
merged 3 commits into from
Jan 16, 2019
Merged

Test pop with default argument #380

merged 3 commits into from
Jan 16, 2019

Conversation

jakirkham
Copy link
Member
@jakirkham jakirkham commented Jan 4, 2019

Adds another case to test_pop for stores generally, which merely tests if pop can handle the default argument correctly when no key can be found.

TODO:

  • Add unit tests and/or doctests in docstrings
  • Add docstrings and API docs for any new/modified user-facing classes and functions
  • New/modified features documented in docs/tutorial.rst
  • Changes documented in docs/release.rst
  • Docs build locally (e.g., run tox -e docs)
  • AppVeyor and Travis CI passes
  • Test coverage is 100% (Coveralls passes)

Adds another case to `test_pop` for stores generally, which merely tests
if `pop` can handle the default argument correctly when no key can be
found.
Some implementations of `pop` might carelessly set the `default` to
`None` when not passed. However this would make it impossible to
distinguish the case where the user passed `None` for the `default`
intentionally versus not passing anything for the `default`. The result
being both cases would raise a `KeyError`, but the error would be
incorrect in the first case. The usual way of solving this is to create
some dummy object and make that the `default` when if it is not set.
That way one can compare if the dummy object is seen and only raise
then. Thus passing `None` for the `default` would not error, but return
`None` if the `key` does not exist as expected. This test is added to
catch this potential oversight.
@jakirkham
Copy link
Member Author

Thoughts @zarr-developers/core-devs?

@jakirkham jakirkham merged commit fefce3b into zarr-developers:master Jan 16, 2019
@jakirkham jakirkham deleted the test_pop_default branch January 16, 2019 01:20
@jakirkham
Copy link
Member Author

Merging to get these additional tests in. If there are any issues, please let me know and we can work to address them.

@jakirkham jakirkham added this to the v2.3 milestone Feb 17, 2019
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.

1 participant
0