From 35166063cf6d42c800ac6715d6e924684297699a Mon Sep 17 00:00:00 2001 From: Zach Sherman <19153455+zssherman@users.noreply.github.com> Date: Tue, 8 Oct 2024 10:38:33 -0500 Subject: [PATCH] TST: Update test for windows builds, remove try statement for geotiff. (#1660) * TST: Update test for windows builds. * MNT: Remove unused parameter. * FIX: Update with statement. --- tests/io/test_output_to_geotiff.py | 71 ++++++++++++------------------ 1 file changed, 28 insertions(+), 43 deletions(-) diff --git a/tests/io/test_output_to_geotiff.py b/tests/io/test_output_to_geotiff.py index 7f9259b0e1..e2409a54b5 100644 --- a/tests/io/test_output_to_geotiff.py +++ b/tests/io/test_output_to_geotiff.py @@ -1,11 +1,9 @@ """ Unit Tests for Py-ART's output_to_geotiff.py module. """ import warnings -from pathlib import Path import numpy as np import pytest -from PIL import Image import pyart @@ -157,27 +155,20 @@ def test_write_grid_geotiff_missing_field(): ) def test_write_grid_geotiff_transparent_background(): grid = make_tiny_grid_with_mask() - - try: - with pyart.testing.InTemporaryDirectory() as tmpdir: - tmp = Path(tmpdir) - outname = tmp / "transparent_bg.tif" - pyart.io.write_grid_geotiff( - grid, - str(outname), - "reflectivity", - rgb=True, - cmap="pyart_HomeyerRainbow", - vmin=0, - vmax=40, - transparent_bg=True, - opacity=1, - ) - imgname = outname.rename(tmp / "transparent_bg.tiff") - img = Image.open(imgname) - img.show() - except PermissionError: - pass + with pyart.testing.InTemporaryDirectory(): + pyart.io.write_grid_geotiff( + grid, + "transparent.foo", + "reflectivity", + rgb=True, + cmap="pyart_HomeyerRainbow", + vmin=0, + vmax=40, + transparent_bg=True, + opacity=1, + ) + with open("transparent.foo", "rb") as f: + assert len(f.read()) > 0 @pytest.mark.skipif( @@ -185,23 +176,17 @@ def test_write_grid_geotiff_transparent_background(): ) def test_write_grid_geotiff_opacity(): grid = make_tiny_grid_with_mask() - try: - with pyart.testing.InTemporaryDirectory() as tmpdir: - tmp = Path(tmpdir) - outname = tmp / "opacity.tif" - pyart.io.write_grid_geotiff( - grid, - str(outname), - "reflectivity", - rgb=True, - cmap="pyart_HomeyerRainbow", - vmin=0, - vmax=40, - transparent_bg=False, - opacity=0.25, - ) - imgname = outname.rename(tmp / "opacity.tiff") - img = Image.open(imgname) - img.show() - except PermissionError: - pass + with pyart.testing.InTemporaryDirectory(): + pyart.io.write_grid_geotiff( + grid, + "opacity.foo", + "reflectivity", + rgb=True, + cmap="pyart_HomeyerRainbow", + vmin=0, + vmax=40, + transparent_bg=False, + opacity=0.25, + ) + with open("opacity.foo", "rb") as f: + assert len(f.read()) > 0