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

Convert graphics testing conveniences to PyTest #5832

Merged

Conversation

trexfeathers
Copy link
Contributor

@trexfeathers trexfeathers commented Mar 13, 2024

Make sure you squash merge!

(the commits are a bit of a mess)

Copy link

codecov bot commented Mar 13, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 89.74%. Comparing base (fa86a4f) to head (db0da75).
Report is 11 commits behind head on FEATURE_pytest_conversion.

Additional details and impacted files
@@                    Coverage Diff                     @@
##           FEATURE_pytest_conversion    #5832   +/-   ##
==========================================================
  Coverage                      89.74%   89.74%           
==========================================================
  Files                             92       92           
  Lines                          22940    22940           
  Branches                        5462     5462           
==========================================================
  Hits                           20588    20588           
  Misses                          1620     1620           
  Partials                         732      732           

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@trexfeathers
Copy link
Contributor Author

The tests below (from these changes) demonstrate that check_graphics_caller() can support PyTest style tests. If you click the below you will note the full set of ✔ checks. I will revert this demo so that test_plot.py can be converted in a dedicated PR.

@tests.skip_data
@tests.skip_plot
class Test1dScatter:
@pytest.fixture(autouse=True)
def set_draw_method(self):
self.draw_method = iplt.scatter
@pytest.fixture(autouse=True)
def setup(self, check_graphic_caller):
self.cube = iris.load_cube(
tests.get_data_path(("NAME", "NAMEIII_trajectory.txt")),
"Temperature",
)
self.check_graphic = check_graphic_caller
def test_coord_coord(self):
x = self.cube.coord("longitude")
y = self.cube.coord("altitude")
c = self.cube.data
self.draw_method(x, y, c=c, edgecolor="none")
self.check_graphic()
def test_coord_coord_map(self):
x = self.cube.coord("longitude")
y = self.cube.coord("latitude")
c = self.cube.data
self.draw_method(x, y, c=c, edgecolor="none")
plt.gca().coastlines("110m")
self.check_graphic()
def test_coord_cube(self):
x = self.cube.coord("latitude")
y = self.cube
c = self.cube.coord("Travel Time").points
self.draw_method(x, y, c=c, edgecolor="none")
self.check_graphic()
def test_cube_coord(self):
x = self.cube
y = self.cube.coord("altitude")
c = self.cube.coord("Travel Time").points
self.draw_method(x, y, c=c, edgecolor="none")
self.check_graphic()
def test_cube_cube(self):
x = iris.load_cube(
tests.get_data_path(("NAME", "NAMEIII_trajectory.txt")),
"Rel Humidity",
)
y = self.cube
c = self.cube.coord("Travel Time").points
self.draw_method(x, y, c=c, edgecolor="none")
self.check_graphic()
@tests.skip_data
@tests.skip_plot
class Test1dQuickplotScatter(Test1dScatter):
@pytest.fixture(autouse=True)
def set_draw_method(self):
self.draw_method = qplt.scatter

@trexfeathers trexfeathers marked this pull request as ready for review March 13, 2024 18:25
Copy link
Contributor

@ESadek-MO ESadek-MO left a comment

Choose a reason for hiding this comment

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

Thanks @trexfeathers, LGTM.

Docstrings good and code clean :)

lib/iris/tests/graphics/README.md Show resolved Hide resolved
@ESadek-MO ESadek-MO merged commit dfd25e2 into SciTools:FEATURE_pytest_conversion Mar 14, 2024
19 checks passed
@trexfeathers trexfeathers deleted the graphics_tests_new branch May 3, 2024 15:21
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants