-
Notifications
You must be signed in to change notification settings - Fork 0
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
Add tests for sample data repo #13
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
When I try to run the tests, it fails with:
FAILED tests/test_sample_data_loader.py::test_load_timeseries_cubes_invalid - Failed: DID NOT RAISE <class 'ValueError'>
It would be good to add a GitHub action to show that this PR actually works. Do you have the permissions to do that? If not, I can do it.
Works fine here, can you post the tracelog?
Agreed, but let's do that in a separate PR once this is merged. I made a new issue here: #13 |
That's why it's useful to run the tests on an independent machine.. Here goes: $ pytest
=========================================================== test session starts ============================================================
platform linux -- Python 3.8.6, pytest-6.1.2, py-1.9.0, pluggy-0.13.1
rootdir: /home/bandela/src/esmvalgroup/esmvaltool_sample_data
plugins: xdist-2.1.0, env-0.6.2, mock-3.3.1, forked-1.3.0, flake8-1.0.6, metadata-1.11.0, html-3.0.0, cov-2.10.1
collected 3 items
tests/test_sample_data_loader.py ..F [100%]
================================================================= FAILURES =================================================================
____________________________________________________ test_load_timeseries_cubes_invalid ____________________________________________________
def test_load_timeseries_cubes_invalid():
"""Test for fail on wrong input parameter."""
with pytest.raises(ValueError):
> load_timeseries_cubes("FAIL")
E Failed: DID NOT RAISE <class 'ValueError'>
tests/test_sample_data_loader.py:21: Failed
============================================================= warnings summary =============================================================
../../../conda/envs/esmvaltool/lib/python3.8/site-packages/pyke/knowledge_engine.py:28
/home/bandela/conda/envs/esmvaltool/lib/python3.8/site-packages/pyke/knowledge_engine.py:28: DeprecationWarning: the imp module is deprecated in favour of importlib; see the module's documentation for alternative uses
import imp
tests/test_sample_data_loader.py: 336 warnings
/home/bandela/conda/envs/esmvaltool/lib/python3.8/site-packages/iris/fileformats/cf.py:358: DeprecationWarning: tostring() is deprecated. Use tobytes() instead.
nc_var_att = getattr(nc_var, cls.cf_identity, None)
tests/test_sample_data_loader.py: 2421 warnings
/home/bandela/conda/envs/esmvaltool/lib/python3.8/site-packages/iris/fileformats/cf.py:1139: DeprecationWarning: tostring() is deprecated. Use tobytes() instead.
value = dataset.getncattr(attr)
tests/test_sample_data_loader.py: 1332 warnings
/home/bandela/conda/envs/esmvaltool/lib/python3.8/site-packages/iris/fileformats/cf.py:191: DeprecationWarning: tostring() is deprecated. Use tobytes() instead.
value = getattr(self.cf_data, name)
tests/test_sample_data_loader.py: 86 warnings
/home/bandela/conda/envs/esmvaltool/lib/python3.8/site-packages/iris/fileformats/cf.py:221: DeprecationWarning: tostring() is deprecated. Use tobytes() instead.
return tuple((attr, self.getncattr(attr)) for attr in
-- Docs: https://docs.pytest.org/en/stable/warnings.html
========================================================= short test summary info ==========================================================
FAILED tests/test_sample_data_loader.py::test_load_timeseries_cubes_invalid - Failed: DID NOT RAISE <class 'ValueError'>
================================================ 1 failed, 2 passed, 4176 warnings in 5.85s ================================================ |
Useful, yes, but it wouldn't solve the issue you are having. Can you check what the output is: import esmvaltool_sample_data
esmvaltool_sample_data.load_timeseries_cubes('FAIL') |
It would make reviewing this pull request a lot easier though. The output is |
The typo was my bad, but that output is impossible, because it checks the argument and raises a
Are you sure you are on the latest version of this branch? |
Maybe I wasn't, I pulled the latest version of the branch and now I get:
and
|
This PR adds some basic tests for the sample data repository functionality.
Closes #10