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

Various fixes to improve running of pytest suite #327

Merged
merged 1 commit into from
Mar 13, 2024

Conversation

stephankramer
Copy link
Contributor

  • test_sed_slide.py: this was previously a run-alone python script, but since pytest tries to import every python file starting with test_ it means this test was always being run even when trying to run a single actual pytest test. Now turned into an actual test
  • test_examples: this test runs all python files (except those excluded) found in the examples/ directories. However the id was set to just the basename of these python files, and since there are multiple files with the same name in different subdirectories of examples/, you end up with multiple tests with the exact same name, meaning you can't easily work out which one has actually failed from the actions logs and also you can't run them individiually. Now just using the full path as the id. Note that the -k argument for pytest does not like forward slashes. If you want to run a specific test example however you can run something like:

pytest -k"tohoku_inversion and inverse_problem.py" test/examples/

  • test_bath_smoothing.py renamed to bath_smoothing_test.py, again so it doesn't accidentily get picked up if you forget to tell pytest to only look in test/

jwallwork23
jwallwork23 previously approved these changes Feb 29, 2024
Copy link
Contributor

@jwallwork23 jwallwork23 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These changes make sense to me, yeah! Thanks.

* test_sed_slide.py: this was previously a run-alone python script, but
since pytest tries to import every python file starting with test_ it
means this test was always being run even when trying to run a single actual pytest test. Now turned into an actual test
* test_examples: this test runs all python files (except those excluded)
found in the examples/ directories. However the id was set to just the
basename of these python files, and since there are multiple files with
the same name in different subdirectories of examples/, you end up with
multiple tests with the exact same name, meaning you can't easily work
out which one has actually failed from the actions logs and also you
can't run them individiually. Now just using the full path as the id.
Note that the -k argument for pytest does not like forward slashes. If
you want to run a specific test example however you can run something
like:

pytest -k"tohoku_inversion and inverse_problem.py" test/examples/

you want to run a specific single test using -k
* test_bath_smoothing renamed to bath_smoothin_test, again so it doesn't
  accidentily get picked up if you forget to tell pytest to only look in test/

Fixes after master merge
@stephankramer stephankramer merged commit e415a7a into master Mar 13, 2024
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants