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

pytest is an unnecessary dependency? #2068

Closed
TomAugspurger opened this issue Aug 7, 2024 · 4 comments · Fixed by #2069
Closed

pytest is an unnecessary dependency? #2068

TomAugspurger opened this issue Aug 7, 2024 · 4 comments · Fixed by #2069
Labels
bug Potential issues with the zarr-python library

Comments

@TomAugspurger
Copy link
Contributor

Zarr version

main

Numcodecs version

na

Python Version

na

Operating System

na

Installation

na

Description

'pytest'
has pytest as a required dependency (note that this isn't as an dev-only extras dependency).

Looks like that was added in #1785. It wasn't discussed, so it was presumably intended to be a dev-only dependency.

Slightly related, but would you be open to defining tool.hath.envs.test as a standard optional dependency?

[tool.hatch.envs.test]
https://hatch.pypa.io/latest/config/environment/overview/#features recommends doing something like

[tool.hatch.envs.test]
features = [
  "test",
]

which should work for both.

Steps to reproduce

na

Additional output

No response

@TomAugspurger TomAugspurger added the bug Potential issues with the zarr-python library label Aug 7, 2024
@d-v-b
Copy link
Contributor

d-v-b commented Aug 7, 2024

we need pytest because of this class

@TomAugspurger
Copy link
Contributor Author

TomAugspurger commented Aug 7, 2024

Thanks. I see that the __init__.py guards against pytest missing:

if importlib.util.find_spec("pytest") is not None:
from zarr.testing.store import StoreTests
else:
warnings.warn("pytest not installed, skipping test suite", stacklevel=2)
. So maybe the intended behavior is to just not have that class be importable if pytest isn't installed?

Here's the behavior I see in an environment without pytest:

In [1]: import zarr

In [2]: import zarr.testing
<ipython-input-2-02d20f6cfc6f>:1: UserWarning: pytest not installed, skipping test suite
  import zarr.testing

In [3]: zarr.testing.StoreTests
---------------------------------------------------------------------------
AttributeError                            Traceback (most recent call last)
Cell In[3], line 1
----> 1 zarr.testing.StoreTests

AttributeError: module 'zarr.testing' has no attribute 'StoreTests'

@d-v-b
Copy link
Contributor

d-v-b commented Aug 7, 2024

. So maybe the intended behavior is to just not have that class be importable if pytest isn't installed?

This seems right! (@jhamman feel free to issue a correction here).

@jhamman
Copy link
Member

jhamman commented Aug 8, 2024

Pytest should not be a required dependency so +1 to removing it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Potential issues with the zarr-python library
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants