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

Tests in examples_test.py fail when run from outside the test dir #474

Open
elcorto opened this issue Aug 3, 2023 · 0 comments · May be fixed by #517
Open

Tests in examples_test.py fail when run from outside the test dir #474

elcorto opened this issue Aug 3, 2023 · 0 comments · May be fixed by #517

Comments

@elcorto
Copy link
Member

elcorto commented Aug 3, 2023

The issue doesn't affect the CI since examples are excluded.

These tests need to be run from within /path/to/mala/test/ because (i) of the usage of relative paths in runpy.run_path() and (ii) since all examples save their artifacts to a relative path, so when run from

/path/to/mala/test/

those will end up there. Also examples expect artifacts which they read, such as "be_model.zip", to be in the dir where the script is executed in. An obvious fix to allow running pytest from anywhere, in particular from the package root dir, is to use absolute paths. Then we pollute this dir with artifacts but can clean that with running /path/to/mala/test/clean.sh in the package root. However, a more clean way would be:

  • use absolute paths
  • execute tests in a temp dir, using tempfile.TemporaryDirectory or pytest tooling

See e.g. here for a possible way to do it.

@pcagas pcagas linked a pull request May 30, 2024 that will close this issue
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant