scipp / scippnexus

h5py-like utility for NeXus files with seamless scipp integration
https://scipp.github.io/scippnexus/
BSD 3-Clause "New" or "Revised" License
3 stars 3 forks source link

Use pytest importlib import mode #192

Closed jl-wynen closed 5 months ago

jl-wynen commented 5 months ago

Part of https://github.com/scipp/scipp/issues/3344

I tried converting externalfile into a fixture so that tests don't need the marker, i.e., something along the lines of

# in conftest.py
@pytest.mark.fixture(scope='session')
def externalfile():
    from externalfile import ExternelFile
    return ExternalFile()

# in test file
def test_foo(externalfile):
    path = externalfile.get_path(name)
    ...

Where ExternalFile is a simple class that holds the pooch inventory. Unfortunately, I didn't find a way to skip those tests via a marker. So I think we would have to move to a dedicated command line option, see the setup in Scitacean: https://github.com/SciCatProject/scitacean/blob/main/tests/conftest.py

SimonHeybrock commented 5 months ago

I think externalfile might be used only by a single test file. Can we simply move the code there?

jl-wynen commented 5 months ago

We could. But do you want to keep it that way when we have more tests / test files?

SimonHeybrock commented 5 months ago

Should we consider making this data part of the package, instead of just the tests?

jl-wynen commented 5 months ago

Just so we slightly simplify the import in the tests? I would say no, because it is not useful to package users.