Move tests to the toplevel#2057
Conversation
The main reason this has become relevant now is because Zarr 3 ships a
pytest plugin. The pytest plugin is loaded early during setup and
imports `zarr`, which imports `fsspec` from the _installed_ copy before
pytest even looks for tests. But tests are excluded from the installed
copy (as configured in hatch.) So to run tests against an installed
copy, we need to point pytest at the original source, but then it sees
that those tests are in an `fsspec` module and gets confused:
```
==================================== ERRORS ====================================
___________________________ ERROR collecting fsspec ____________________________
/usr/lib/python3.15/site-packages/_pytest/config/__init__.py:731: in _importconftest
mod = import_path(
/usr/lib/python3.15/site-packages/_pytest/pathlib.py:610: in import_path
raise ImportPathMismatchError(module_name, module_file, path)
E _pytest.pathlib.ImportPathMismatchError: ('fsspec.conftest',
'/builddir/build/BUILD/python-fsspec-2026.6.0-build/BUILDROOT/usr/lib/python3.15/site-packages/fsspec/conftest.py',
PosixPath('/builddir/build/BUILD/python-fsspec-2026.6.0-build/filesystem_spec-2026.6.0/fsspec/conftest.py'))
=========================== short test summary info ============================
ERROR fsspec - _pytest.pathlib.ImportPathMismatchError: ('fsspec.conftest', '...
```
This works in current CI because all installs are editable, meaning the
installed copy is the same as the source copy, and tests are always
visible.
|
I am uncertain why |
|
Before going further here, is there no pytest flag on the other end that might fix this without any changes here? I understand that including the tests is no longer the done thing (since a long time), but it's still not a burden. |
|
I tried passing Unfortunately, it got stuck at I think that If you think that skipping these 2 tests is reasonably safe, then I could implement that downstream and not continue here. |
Sounds fine to me
Hah, not too close :) |
|
Wait, I'm sorry, I accidentally tested with Zarr 2 twice. With Zarr 3, I get a bunch of this: The problem is that |
|
Sadly relative imports are broken just the same: I suppose I could try deleting the zarr pytest plugin; it doesn't seem super important. |
This is implementing #1611 (comment) and the main reason this has become relevant now is because Zarr 3 ships a pytest plugin. The pytest plugin is loaded early during setup and imports
zarr, which importsfsspecfrom the installed copy before pytest even looks for tests. But tests are excluded from the installed copy (as configured in hatch.) So to run tests against an installed copy, we need to point pytest at the original source, but then it sees that those tests are in anfsspecmodule and gets confused:This works in current CI because all installs are editable, meaning the installed copy is the same as the source copy, and tests are always visible.