Closed ghiggi closed 7 months ago
Attention: 28 lines
in your changes are missing coverage. Please review.
Comparison is base (
c240c04
) 94.09% compared to head (8d19a4e
) 93.88%. Report is 10 commits behind head on main.
Files | Patch % | Lines |
---|---|---|
pyresample/test/test_geometry/conftest.py | 74.54% | 28 Missing :warning: |
:umbrella: View full report in Codecov by Sentry.
:loudspeaker: Have feedback on the report? Share it here.
@mraspaud @djhoese ready for review ;)
Regarding coverage of the fixtures, are we sure they are used?
@mraspaud a couple of these fixtures are not yet used but will be in one of the next PRs.
Please let me pass this ... I am already trying to keep track of hundreds of stuffs :)
Can I move the TestBoundary
and TestGeostationaryTools
classes into a new test_area_boundary.py
file?
@mraspaud a couple of these fixtures are not yet used but will be in one of the next PRs. Please let me pass this ... I am already trying to keep track of hundreds of stuffs :)
I was suspecting as much. Fine by me.
Can I move the
TestBoundary
andTestGeostationaryTools
classes into a newtest_area_boundary.py
file?
Yes. Sorry I thought this PR was ready. If not, make sure to check the Draft option. I almost merged this earlier.
@djhoese also this one I guess is now ready to be merged ;) Have a nice week-end
Lots of pre-commit failures
@djhoese It seems that flake8
does not recognize the area fixtures imported and raises F811
errors
I will look later.
Ok. Pre-commit is happy, but we'll see if all the tests made it through my reworking. Bottom line is that pytest fixtures are magic. You can't import them. They either have to be defined in the current scope (module, class, etc) or in a special conftest.py
module. The conftest.py
module can be in the primary pyresample/test/
directory, but also additionally in each sub-directory of the pyresample/test/
module (ex. test_geometry). This module is automatically run/included when running tests under this particular directory and both the root test/conftest.py
and the subdir test/test_geometry/conftest.py
are included/loaded.
One thing to consider would be modifying the scope of these fixtures by doing pytest.fixture(scope="session")
if we consider them read-only/immutable so that they aren't wastefully recreated every test. It could also be package
scope if package means "sub-package", but I'm not sure on that.
https://docs.pytest.org/en/6.2.x/fixture.html#fixture-scopes
Oh I didn't know that fixtures couldn't be imported. Good to know ... learning new stuffs everyday :smile:
I try to use pytest.fixture(scope="session")
but I got:
ScopeMismatch: You tried to access the function scoped fixture create_test_area with a session scoped request object, involved factories
Any idea on what is going on?
If we use pytest.fixture(scope="session")
we also implicitly test that modification in place does not occur right? We don't risk to have problems when we test i.e. caching (i.e on class attributes?)
Ah, forget the scoping then. Although...I suppose create_test_area
could also be scoped to session... :man_shrugging: I'm not sure it is worth the effort. Especially in this PR. And yes, we assume that the areas aren't being modified in place (which is generally prohibited by checks in the classes properties).
For the error you were getting: it is saying that create_test_area
which is rerun/recreated for every test function is being used by the area fixtures you're making which are session scoped and created once. That logically doesn't make sense: you can't have something that is created once use something that should update every function.
git diff origin/main **/*py | flake8 --diff
This PR
areas.py
TestBoundary
andTestGeostationaryTools
classes fromtest_area.py
into a newtest_area_boundary.py
file.TestSwathBoundary
andTestSwathBboxLonLats
classes fromtest_swath.py
into a newtest_swath_boundary.py
file.This refactor reduce the code length of such test units and facilitate the addition of new test units in the upcoming PRs.