Remove unittest reliance on optional dependencies#6976
Remove unittest reliance on optional dependencies#6976ESadek-MO wants to merge 25 commits intoSciTools:mainfrom
Conversation
|
This can be reviewed, all changes are for this, but I messed up branch management so will either need a rebase or a copy over |
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #6976 +/- ##
==========================================
+ Coverage 90.11% 90.12% +0.01%
==========================================
Files 91 91
Lines 24912 24951 +39
Branches 4675 4683 +8
==========================================
+ Hits 22449 22488 +39
Misses 1684 1684
Partials 779 779 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
pp-mo
left a comment
There was a problem hiding this comment.
There's been a bit of confusion with files that should have moved from unit to integration,
but the old place didn't get deleted.
Otherwise, looking pretty good !
| try: | ||
| import stratify | ||
|
|
||
| from iris.experimental.stratify import relevel | ||
| except ImportError: | ||
| stratify = None | ||
|
|
||
|
|
||
| @_shared_utils.skip_stratify | ||
| class Test: |
There was a problem hiding this comment.
Do we actually need to be able to run integration tests with no stratify available?
If not, we don't need all this.
... and if we do need it, then there's a neat standard PyTest way to skip a whole file of tests when an import is unavailable,
called importorskip
There was a problem hiding this comment.
I would still like this here, as a just in case. However, I don't think refactoring falls within the scope here so much. If I find there's time to do this after the rest of the work has been done, I will, else I think this becomes a standalone issue, perhaps.
| _shared_utils.assert_array_equal(series, cube.data) | ||
| _shared_utils.assert_array_equal(series.index, expected_index) | ||
| expected_index = dim_coord.points[0] | ||
| expected_data = cube.data |
There was a problem hiding this comment.
This new version of the test is all OK as the new unit test,
but it seems to have lost a lot, including all the tests 'test_masked', 'test_time_standard', 'test_time_360' and 'test_copy_masked_true'.
Did you mean to add a copy of the old version (or parts of it) in tests/integration ?
There was a problem hiding this comment.
FWIW I think you could replace all this with "importorskip", since IIUC the whole file will be skipped if there is no pandas.
| # | ||
| # This file is part of Iris and is released under the BSD license. | ||
| # See LICENSE in the root of the repository for full licensing details. | ||
| """Tests for :func:`iris.experimental.regrid.regrid_conservative_via_esmpy`.""" |
There was a problem hiding this comment.
Since it doesn't say "unit tests", this doesn't need to be changed to "integration" (!) 👍
BUT.. this should appear as a file move, not a new file.
You need to delete the original lib/iris/tests/experimental/regrid/test_regrid_conservative_via_esmpy.py
| @@ -0,0 +1,18 @@ | |||
| <?xml version="1.0" ?> | |||
There was a problem hiding this comment.
Should appear as a move, not a new file.
Need to delete lib/iris/tests/results/unit/experimental/stratify/relevel/multi_dim_target_levels.cml
| # | ||
| # This file is part of Iris and is released under the BSD license. | ||
| # See LICENSE in the root of the repository for full licensing details. | ||
| """Unit tests for :func:`iris.util.mask_cube_from_shapefile`.""" |
There was a problem hiding this comment.
Needs rename
| """Unit tests for :func:`iris.util.mask_cube_from_shapefile`.""" | |
| """Integration tests for :func:`iris.util.mask_cube_from_shapefile`.""" |
pp-mo
left a comment
There was a problem hiding this comment.
More.
Not sure why it wouldn't let me add this one to the existing review, I'm sure it let me do that with the previous one ??
|
|
||
| import numpy as np | ||
| import pytest | ||
| from shapely.geometry import box |
There was a problem hiding this comment.
Nothing wrong with this,
But weirdly, we still have the same line in the original source
tests/unit/util/test_mask_cube_from_shapefile.py.
So, that will fail when remove the deps, and seems to need fixing somehow.
There was a problem hiding this comment.
Please check I've done this as you meant!
ESadek-MO
left a comment
There was a problem hiding this comment.
Also needs a whatsnew!
🚀 Pull Request
Description
Consult Iris pull request check list
Add any of the below labels to trigger actions on this PR: