If the test suite is executed via pytest from anywhere other than the top-level directory of the package, all of the test_cli.py tests will error out with FileNotFoundError:
FAILED test_cli.py::test_build[v2024-01-01] - FileNotFoundError: [Errno 2] No such file or directory: 'tests/data/access-om2/metadata.yaml'
FAILED test_cli.py::test_build[2024-01-01] - FileNotFoundError: [Errno 2] No such file or directory: 'tests/data/access-om2/metadata.yaml'
FAILED test_cli.py::test_build_bad_metadata - FileNotFoundError: [Errno 2] No such file or directory: 'tests/data/access-om2/metadata-bad.yaml'
FAILED test_cli.py::test_build_repeat_nochange - FileNotFoundError: [Errno 2] No such file or directory: 'tests/data/access-om2/metadata.yaml'
FAILED test_cli.py::test_build_repeat_adddata - FileNotFoundError: [Errno 2] No such file or directory: 'tests/data/access-om2/metadata.yaml'
FAILED test_cli.py::test_build_existing_data[v2001-01-01-v2099-01-01] - FileNotFoundError: [Errno 2] No such file or directory: 'tests/data/access-om2/metadata.yaml'
FAILED test_cli.py::test_build_existing_data[None-v2099-01-01] - FileNotFoundError: [Errno 2] No such file or directory: 'tests/data/access-om2/metadata.yaml'
FAILED test_cli.py::test_build_existing_data[v2001-01-01-None] - FileNotFoundError: [Errno 2] No such file or directory: 'tests/data/access-om2/metadata.yaml'
FAILED test_cli.py::test_build_existing_data_existing_old_cat[v2001-01-01-v2099-01-01] - FileNotFoundError: [Errno 2] No such file or directory: 'tests/data/access-om2/metadata.yaml'
FAILED test_cli.py::test_build_existing_data_existing_old_cat[None-v2099-01-01] - FileNotFoundError: [Errno 2] No such file or directory: 'tests/data/access-om2/metadata.yaml'
FAILED test_cli.py::test_build_existing_data_existing_old_cat[v2001-01-01-None] - FileNotFoundError: [Errno 2] No such file or directory: 'tests/data/access-om2/metadata.yaml'
FAILED test_cli.py::test_build_repeat_renamecatalogyaml[v2001-01-01-v2099-01-01] - FileNotFoundError: [Errno 2] No such file or directory: 'tests/data/access-om2/metadata.yaml'
FAILED test_cli.py::test_build_repeat_renamecatalogyaml[None-v2099-01-01] - FileNotFoundError: [Errno 2] No such file or directory: 'tests/data/access-om2/metadata.yaml'
FAILED test_cli.py::test_build_repeat_renamecatalogyaml[v2001-01-01-None] - FileNotFoundError: [Errno 2] No such file or directory: 'tests/data/access-om2/metadata.yaml'
FAILED test_cli.py::test_build_repeat_altercatalogstruct[v2001-01-01-v2099-01-01] - FileNotFoundError: [Errno 2] No such file or directory: 'tests/data/access-om2/metadata.yaml'
FAILED test_cli.py::test_build_repeat_altercatalogstruct[None-v2099-01-01] - FileNotFoundError: [Errno 2] No such file or directory: 'tests/data/access-om2/metadata.yaml'
FAILED test_cli.py::test_build_repeat_altercatalogstruct[v2001-01-01-None] - FileNotFoundError: [Errno 2] No such file or directory: 'tests/data/access-om2/metadata.yaml'
FAILED test_cli.py::test_build_repeat_altercatalogstruct_multivers[v2001-01-01-v2099-01-01] - FileNotFoundError: [Errno 2] No such file or directory: 'tests/data/access-om2/metadata.yaml'
FAILED test_cli.py::test_build_repeat_altercatalogstruct_multivers[None-v2099-01-01] - FileNotFoundError: [Errno 2] No such file or directory: 'tests/data/access-om2/metadata.yaml'
FAILED test_cli.py::test_build_repeat_altercatalogstruct_multivers[v2001-01-01-None] - FileNotFoundError: [Errno 2] No such file or directory: 'tests/data/access-om2/metadata.yaml'
To Reproduce
Attempt to run pytest from, e.g., inside the tests directory of the package, rather than at the top level.
Additional context
I think the issue is coming from the paths within the test catalog YAML configs being hard-coded with respect to the top-level package directory, e.g., in tests/data/config/access-om2.yaml:
I'm not sure how to fix this yet - we'd need to intercept the read of these YAML files and prepend the absolute test path somehow (via mock or otherwise).
Describe the bug
If the test suite is executed via
pytest
from anywhere other than the top-level directory of the package, all of thetest_cli.py
tests will error out withFileNotFoundError
:To Reproduce
Attempt to run
pytest
from, e.g., inside thetests
directory of the package, rather than at the top level.Additional context
I think the issue is coming from the paths within the test catalog YAML configs being hard-coded with respect to the top-level package directory, e.g., in
tests/data/config/access-om2.yaml
:I'm not sure how to fix this yet - we'd need to intercept the read of these YAML files and prepend the absolute test path somehow (via
mock
or otherwise).