diff --git a/pygmt/tests/test_binstats.py b/pygmt/tests/test_binstats.py index 31a2f072579..3a6c6ede74a 100644 --- a/pygmt/tests/test_binstats.py +++ b/pygmt/tests/test_binstats.py @@ -1,7 +1,7 @@ """ Tests for binstats. """ -import os +from pathlib import Path import numpy.testing as npt from pygmt import binstats @@ -23,7 +23,7 @@ def test_binstats_outgrid(): region="g", ) assert result is None # return value is None - assert os.path.exists(path=tmpfile.name) # check that outgrid exists + assert Path(tmpfile.name).stat().st_size > 0 # check that outgrid exists def test_binstats_no_outgrid(): diff --git a/pygmt/tests/test_blockm.py b/pygmt/tests/test_blockm.py index 41609d36557..9468e19cab5 100644 --- a/pygmt/tests/test_blockm.py +++ b/pygmt/tests/test_blockm.py @@ -1,7 +1,7 @@ """ Tests for blockmean and blockmode. """ -import os +from pathlib import Path import numpy as np import numpy.testing as npt @@ -85,7 +85,7 @@ def test_blockmean_input_filename(): outfile=tmpfile.name, ) assert output is None # check that output is None since outfile is set - assert os.path.exists(path=tmpfile.name) # check that outfile exists at path + assert Path(tmpfile.name).stat().st_size > 0 # check that outfile exists output = pd.read_csv(tmpfile.name, sep="\t", header=None) assert output.shape == (5849, 3) npt.assert_allclose(output.iloc[0], [245.888877, 29.978707, -384.0]) diff --git a/pygmt/tests/test_blockmedian.py b/pygmt/tests/test_blockmedian.py index 591bb4e9739..b627e237905 100644 --- a/pygmt/tests/test_blockmedian.py +++ b/pygmt/tests/test_blockmedian.py @@ -1,7 +1,7 @@ """ Tests for blockmedian. """ -import os +from pathlib import Path import numpy.testing as npt import pandas as pd @@ -82,7 +82,7 @@ def test_blockmedian_input_filename(): outfile=tmpfile.name, ) assert output is None # check that output is None since outfile is set - assert os.path.exists(path=tmpfile.name) # check that outfile exists at path + assert Path(tmpfile.name).stat().st_size > 0 # check that outfile exists output = pd.read_csv(tmpfile.name, sep="\t", header=None) assert output.shape == (5849, 3) npt.assert_allclose(output.iloc[0], [245.88819, 29.97895, -385.0]) diff --git a/pygmt/tests/test_clib.py b/pygmt/tests/test_clib.py index 9120af22d06..e440aaaf627 100644 --- a/pygmt/tests/test_clib.py +++ b/pygmt/tests/test_clib.py @@ -6,6 +6,7 @@ import os from contextlib import contextmanager from itertools import product +from pathlib import Path import numpy as np import numpy.testing as npt @@ -159,7 +160,7 @@ def test_call_module(): with clib.Session() as lib: with GMTTempFile() as out_fname: lib.call_module("info", f"{data_fname} -C ->{out_fname.name}") - assert os.path.exists(out_fname.name) + assert Path(out_fname.name).stat().st_size > 0 output = out_fname.read().strip() assert output == "11.5309 61.7074 -2.9289 7.8648 0.1412 0.9338" diff --git a/pygmt/tests/test_dimfilter.py b/pygmt/tests/test_dimfilter.py index aa94b2f2708..9c8248c9f11 100644 --- a/pygmt/tests/test_dimfilter.py +++ b/pygmt/tests/test_dimfilter.py @@ -1,7 +1,7 @@ """ Tests for dimfilter. """ -import os +from pathlib import Path import pytest import xarray as xr @@ -54,7 +54,7 @@ def test_dimfilter_outgrid(grid, expected_grid): region=[-55, -51, -24, -19], ) assert result is None # return value is None - assert os.path.exists(path=tmpfile.name) # check that outgrid exists + assert Path(tmpfile.name).stat().st_size > 0 # check that outgrid exists temp_grid = load_dataarray(tmpfile.name) xr.testing.assert_allclose(a=temp_grid, b=expected_grid) diff --git a/pygmt/tests/test_figure.py b/pygmt/tests/test_figure.py index 6f316780955..fb590e1295e 100644 --- a/pygmt/tests/test_figure.py +++ b/pygmt/tests/test_figure.py @@ -4,6 +4,7 @@ Doesn't include the plotting commands which have their own test files. """ import os +from pathlib import Path try: import IPython @@ -151,7 +152,7 @@ def test_figure_savefig_filename_with_spaces(): with GMTTempFile(prefix="pygmt-filename with spaces", suffix=".png") as imgfile: fig.savefig(fname=imgfile.name) assert r"\040" not in os.path.abspath(imgfile.name) - assert os.path.exists(imgfile.name) + assert Path(imgfile.name).stat().st_size > 0 def test_figure_savefig(): diff --git a/pygmt/tests/test_filter1d.py b/pygmt/tests/test_filter1d.py index 5f2f63f97ed..c5cb2b5f459 100644 --- a/pygmt/tests/test_filter1d.py +++ b/pygmt/tests/test_filter1d.py @@ -1,8 +1,7 @@ """ Tests for filter1d. """ - -import os +from pathlib import Path import numpy as np import pandas as pd @@ -38,7 +37,7 @@ def test_filter1d_file_output(data): data=data, filter_type="g5", outfile=tmpfile.name, output_type="file" ) assert result is None # return value is None - assert os.path.exists(path=tmpfile.name) # check that outfile exists + assert Path(tmpfile.name).stat().st_size > 0 # check that outfile exists def test_filter1d_invalid_format(data): @@ -77,7 +76,7 @@ def test_filter1d_outfile_incorrect_output_type(data): data=data, filter_type="g5", outfile=tmpfile.name, output_type="numpy" ) assert result is None # return value is None - assert os.path.exists(path=tmpfile.name) # check that outfile exists + assert Path(tmpfile.name).stat().st_size > 0 # check that outfile exists def test_filter1d_format(data): diff --git a/pygmt/tests/test_grd2xyz.py b/pygmt/tests/test_grd2xyz.py index 4cb172d3684..831e0e93d5e 100644 --- a/pygmt/tests/test_grd2xyz.py +++ b/pygmt/tests/test_grd2xyz.py @@ -1,7 +1,7 @@ """ Tests for grd2xyz. """ -import os +from pathlib import Path import numpy as np import pandas as pd @@ -57,7 +57,7 @@ def test_grd2xyz_file_output(grid): with GMTTempFile(suffix=".xyz") as tmpfile: result = grd2xyz(grid=grid, outfile=tmpfile.name, output_type="file") assert result is None # return value is None - assert os.path.exists(path=tmpfile.name) # check that outfile exists + assert Path(tmpfile.name).stat().st_size > 0 # check that outfile exists def test_grd2xyz_invalid_format(grid): @@ -85,7 +85,7 @@ def test_grd2xyz_outfile_incorrect_output_type(grid): with GMTTempFile(suffix=".xyz") as tmpfile: result = grd2xyz(grid=grid, outfile=tmpfile.name, output_type="numpy") assert result is None # return value is None - assert os.path.exists(path=tmpfile.name) # check that outfile exists + assert Path(tmpfile.name).stat().st_size > 0 # check that outfile exists def test_grd2xyz_pandas_output_with_o(grid): diff --git a/pygmt/tests/test_grdclip.py b/pygmt/tests/test_grdclip.py index 85fd2071286..15d90b49452 100644 --- a/pygmt/tests/test_grdclip.py +++ b/pygmt/tests/test_grdclip.py @@ -1,7 +1,7 @@ """ Tests for grdclip. """ -import os +from pathlib import Path import pytest import xarray as xr @@ -47,7 +47,7 @@ def test_grdclip_outgrid(grid, expected_grid): region=[-53, -49, -19, -16], ) assert result is None # return value is None - assert os.path.exists(path=tmpfile.name) # check that outgrid exists + assert Path(tmpfile.name).stat().st_size > 0 # check that outgrid exists temp_grid = load_dataarray(tmpfile.name) assert temp_grid.dims == ("lat", "lon") assert temp_grid.gmt.gtype == 1 # Geographic grid diff --git a/pygmt/tests/test_grdfill.py b/pygmt/tests/test_grdfill.py index 89e6f3f3129..c6ffe9688d2 100644 --- a/pygmt/tests/test_grdfill.py +++ b/pygmt/tests/test_grdfill.py @@ -1,7 +1,7 @@ """ Tests for grdfill. """ -import os +from pathlib import Path import numpy as np import pytest @@ -115,7 +115,7 @@ def test_grdfill_file_out(grid, expected_grid): with GMTTempFile(suffix=".nc") as tmpfile: result = grdfill(grid=grid, mode="c20", outgrid=tmpfile.name) assert result is None # return value is None - assert os.path.exists(path=tmpfile.name) # check that outgrid exists + assert Path(tmpfile.name).stat().st_size > 0 # check that outfile exists temp_grid = load_dataarray(tmpfile.name) xr.testing.assert_allclose(a=temp_grid, b=expected_grid) diff --git a/pygmt/tests/test_grdfilter.py b/pygmt/tests/test_grdfilter.py index 36e4f213d55..7a75a7b4b77 100644 --- a/pygmt/tests/test_grdfilter.py +++ b/pygmt/tests/test_grdfilter.py @@ -1,7 +1,7 @@ """ Tests for grdfilter. """ -import os +from pathlib import Path import numpy as np import pytest @@ -67,7 +67,7 @@ def test_grdfilter_dataarray_in_file_out(grid, expected_grid): region=[-53, -49, -20, -17], ) assert result is None # return value is None - assert os.path.exists(path=tmpfile.name) # check that outgrid exists + assert Path(tmpfile.name).stat().st_size > 0 # check that outgrid exists temp_grid = load_dataarray(tmpfile.name) xr.testing.assert_allclose(a=temp_grid, b=expected_grid) diff --git a/pygmt/tests/test_grdgradient.py b/pygmt/tests/test_grdgradient.py index 10dd611fd0e..2236c2a7e6e 100644 --- a/pygmt/tests/test_grdgradient.py +++ b/pygmt/tests/test_grdgradient.py @@ -1,7 +1,7 @@ """ Tests for grdgradient. """ -import os +from pathlib import Path import pytest import xarray as xr @@ -48,7 +48,7 @@ def test_grdgradient_outgrid(grid, expected_grid): grid=grid, outgrid=tmpfile.name, azimuth=10, region=[-53, -49, -20, -17] ) assert result is None # return value is None - assert os.path.exists(path=tmpfile.name) # check that outgrid exists + assert Path(tmpfile.name).stat().st_size > 0 # check that outgrid exists temp_grid = load_dataarray(tmpfile.name) xr.testing.assert_allclose(a=temp_grid, b=expected_grid) diff --git a/pygmt/tests/test_grdhisteq.py b/pygmt/tests/test_grdhisteq.py index a9c9e2704d7..ab6b2315b26 100644 --- a/pygmt/tests/test_grdhisteq.py +++ b/pygmt/tests/test_grdhisteq.py @@ -1,7 +1,7 @@ """ Tests for grdhisteq. """ -import os +from pathlib import Path import numpy as np import pandas as pd @@ -61,7 +61,7 @@ def test_equalize_grid_outgrid_file(grid, expected_grid, region): grid=grid, divisions=2, region=region, outgrid=tmpfile.name ) assert result is None # return value is None - assert os.path.exists(path=tmpfile.name) # check that outgrid exists + assert Path(tmpfile.name).stat().st_size > 0 # check that outgrid exists temp_grid = load_dataarray(tmpfile.name) xr.testing.assert_allclose(a=temp_grid, b=expected_grid) @@ -112,7 +112,7 @@ def test_compute_bins_outfile(grid, expected_df, region): ) assert len(record) == 1 # check that only one warning was raised assert result is None # return value is None - assert os.path.exists(path=tmpfile.name) + assert Path(tmpfile.name).stat().st_size > 0 temp_df = pd.read_csv( filepath_or_buffer=tmpfile.name, sep="\t", diff --git a/pygmt/tests/test_grdlandmask.py b/pygmt/tests/test_grdlandmask.py index 1d796e69922..f5dedf895e3 100644 --- a/pygmt/tests/test_grdlandmask.py +++ b/pygmt/tests/test_grdlandmask.py @@ -1,7 +1,7 @@ """ Tests for grdlandmask. """ -import os +from pathlib import Path import pytest import xarray as xr @@ -39,7 +39,7 @@ def test_grdlandmask_outgrid(expected_grid): with GMTTempFile(suffix=".nc") as tmpfile: result = grdlandmask(outgrid=tmpfile.name, spacing=1, region=[125, 130, 30, 35]) assert result is None # return value is None - assert os.path.exists(path=tmpfile.name) # check that outgrid exists + assert Path(tmpfile.name).stat().st_size > 0 # check that outgrid exists temp_grid = load_dataarray(tmpfile.name) xr.testing.assert_allclose(a=temp_grid, b=expected_grid) diff --git a/pygmt/tests/test_grdproject.py b/pygmt/tests/test_grdproject.py index b8bce36cb6a..f4257c0899d 100644 --- a/pygmt/tests/test_grdproject.py +++ b/pygmt/tests/test_grdproject.py @@ -1,7 +1,7 @@ """ Tests for grdproject. """ -import os +from pathlib import Path import pytest import xarray as xr @@ -53,7 +53,7 @@ def test_grdproject_file_out(grid, expected_grid): region=[-53, -51, -20, -17], ) assert result is None # return value is None - assert os.path.exists(path=tmpfile.name) # check that outgrid exists + assert Path(tmpfile.name).stat().st_size > 0 # check that outgrid exists temp_grid = load_dataarray(tmpfile.name) xr.testing.assert_allclose(a=temp_grid, b=expected_grid) diff --git a/pygmt/tests/test_grdsample.py b/pygmt/tests/test_grdsample.py index fff9617d09d..56111ff5d20 100644 --- a/pygmt/tests/test_grdsample.py +++ b/pygmt/tests/test_grdsample.py @@ -1,7 +1,7 @@ """ Tests for grdsample. """ -import os +from pathlib import Path import pytest import xarray as xr @@ -64,7 +64,7 @@ def test_grdsample_file_out(grid, expected_grid, region, spacing): grid=grid, outgrid=tmpfile.name, spacing=spacing, region=region ) assert result is None # return value is None - assert os.path.exists(path=tmpfile.name) # check that outgrid exists + assert Path(tmpfile.name).stat().st_size > 0 # check that outgrid exists temp_grid = load_dataarray(tmpfile.name) xr.testing.assert_allclose(a=temp_grid, b=expected_grid) diff --git a/pygmt/tests/test_grdtrack.py b/pygmt/tests/test_grdtrack.py index ca1e926fb00..51a3dd9613f 100644 --- a/pygmt/tests/test_grdtrack.py +++ b/pygmt/tests/test_grdtrack.py @@ -2,6 +2,7 @@ Tests for grdtrack. """ import os +from pathlib import Path import numpy as np import numpy.testing as npt @@ -72,7 +73,7 @@ def test_grdtrack_input_csvfile_and_dataarray(dataarray, expected_array): with GMTTempFile() as tmpfile: output = grdtrack(points=POINTS_DATA, grid=dataarray, outfile=tmpfile.name) assert output is None # check that output is None since outfile is set - assert os.path.exists(path=tmpfile.name) # check that outfile exists at path + assert Path(tmpfile.name).stat().st_size > 0 # check that outfile exists output = np.loadtxt(tmpfile.name) npt.assert_allclose(np.array(output), expected_array) diff --git a/pygmt/tests/test_grdvolume.py b/pygmt/tests/test_grdvolume.py index 6ea5025c085..1731bfad4ac 100644 --- a/pygmt/tests/test_grdvolume.py +++ b/pygmt/tests/test_grdvolume.py @@ -1,7 +1,7 @@ """ Tests for grdvolume. """ -import os +from pathlib import Path import numpy as np import numpy.testing as npt @@ -98,4 +98,4 @@ def test_grdvolume_outgrid(grid, region): region=region, ) assert result is None # return value is None - assert os.path.exists(path=tmpfile.name) # check that outfile exists + assert Path(tmpfile.name).stat().st_size > 0 # check that outfile exists diff --git a/pygmt/tests/test_makecpt.py b/pygmt/tests/test_makecpt.py index 22a9ff1a1b8..7a8413d0aa2 100644 --- a/pygmt/tests/test_makecpt.py +++ b/pygmt/tests/test_makecpt.py @@ -2,6 +2,7 @@ Tests for makecpt. """ import os +from pathlib import Path import numpy as np import pytest @@ -76,7 +77,7 @@ def test_makecpt_output_cpt_file(): """ with GMTTempFile(suffix=".cpt") as cptfile: makecpt(output=cptfile.name) - assert os.path.exists(cptfile.name) + assert Path(cptfile.name).stat().st_size > 0 def test_makecpt_blank_output(): diff --git a/pygmt/tests/test_nearneighbor.py b/pygmt/tests/test_nearneighbor.py index 222a60e3caf..e94054b6fce 100644 --- a/pygmt/tests/test_nearneighbor.py +++ b/pygmt/tests/test_nearneighbor.py @@ -1,7 +1,7 @@ """ Tests for nearneighbor. """ -import os +from pathlib import Path import numpy as np import numpy.testing as npt @@ -79,7 +79,7 @@ def test_nearneighbor_with_outgrid_param(ship_data): search_radius="10m", ) assert output is None # check that output is None since outgrid is set - assert os.path.exists(path=tmpfile.name) # check that outgrid exists at path + assert Path(tmpfile.name).stat().st_size > 0 # check that outgrid exists with xr.open_dataarray(tmpfile.name) as grid: assert isinstance(grid, xr.DataArray) # ensure netcdf grid loads ok assert grid.shape == (121, 121) diff --git a/pygmt/tests/test_project.py b/pygmt/tests/test_project.py index a08de3e597d..b11154132f0 100644 --- a/pygmt/tests/test_project.py +++ b/pygmt/tests/test_project.py @@ -1,7 +1,7 @@ """ Tests for project. """ -import os +from pathlib import Path import numpy as np import numpy.testing as npt @@ -64,7 +64,7 @@ def test_project_output_filename(dataframe): outfile=tmpfile.name, ) assert output is None # check that output is None since outfile is set - assert os.path.exists(path=tmpfile.name) # check that outfile exists at path + assert Path(tmpfile.name).stat().st_size > 0 # check that outfile exists output = pd.read_csv(tmpfile.name, sep="\t", header=None) assert output.shape == (1, 6) npt.assert_allclose( diff --git a/pygmt/tests/test_select.py b/pygmt/tests/test_select.py index 0f9dbce6b0d..4716ef6313e 100644 --- a/pygmt/tests/test_select.py +++ b/pygmt/tests/test_select.py @@ -1,7 +1,7 @@ """ Tests for select. """ -import os +from pathlib import Path import numpy.testing as npt import pandas as pd @@ -58,7 +58,7 @@ def test_select_input_filename(): outfile=tmpfile.name, ) assert output is None # check that output is None since outfile is set - assert os.path.exists(path=tmpfile.name) + assert Path(tmpfile.name).stat().st_size > 0 output = pd.read_csv(tmpfile.name, sep="\t", header=None) assert output.shape == (5, 3) npt.assert_allclose(output.median(), [250.12149, 26.04296, -674.0]) diff --git a/pygmt/tests/test_sph2grd.py b/pygmt/tests/test_sph2grd.py index 316e6d52408..96e22975d17 100644 --- a/pygmt/tests/test_sph2grd.py +++ b/pygmt/tests/test_sph2grd.py @@ -1,7 +1,7 @@ """ Tests for sph2grd. """ -import os +from pathlib import Path import numpy.testing as npt from pygmt import sph2grd @@ -17,7 +17,7 @@ def test_sph2grd_outgrid(): data="@EGM96_to_36.txt", outgrid=tmpfile.name, spacing=1, region="g" ) assert result is None # return value is None - assert os.path.exists(path=tmpfile.name) # check that outgrid exists + assert Path(tmpfile.name).stat().st_size > 0 # check that outgrid exists def test_sph2grd_no_outgrid(): diff --git a/pygmt/tests/test_sphdistance.py b/pygmt/tests/test_sphdistance.py index 8a6840cc5b0..d87805fd76d 100644 --- a/pygmt/tests/test_sphdistance.py +++ b/pygmt/tests/test_sphdistance.py @@ -1,7 +1,7 @@ """ Tests for sphdistance. """ -import os +from pathlib import Path import numpy as np import numpy.testing as npt @@ -45,7 +45,7 @@ def test_sphdistance_outgrid(array): data=array, outgrid=tmpfile.name, spacing=1, region=[82, 87, 22, 24] ) assert result is None # return value is None - assert os.path.exists(path=tmpfile.name) # check that outgrid exists + assert Path(tmpfile.name).stat().st_size > 0 # check that outgrid exists def test_sphdistance_no_outgrid(array): diff --git a/pygmt/tests/test_sphinterpolate.py b/pygmt/tests/test_sphinterpolate.py index 741d99f2338..fdc40779cd9 100644 --- a/pygmt/tests/test_sphinterpolate.py +++ b/pygmt/tests/test_sphinterpolate.py @@ -1,7 +1,7 @@ """ Tests for sphinterpolate. """ -import os +from pathlib import Path import numpy.testing as npt import pytest @@ -25,7 +25,7 @@ def test_sphinterpolate_outgrid(mars): with GMTTempFile(suffix=".nc") as tmpfile: result = sphinterpolate(data=mars, outgrid=tmpfile.name, spacing=1, region="g") assert result is None # return value is None - assert os.path.exists(path=tmpfile.name) # check that outgrid exists + assert Path(tmpfile.name).stat().st_size > 0 # check that outgrid exists def test_sphinterpolate_no_outgrid(mars): diff --git a/pygmt/tests/test_surface.py b/pygmt/tests/test_surface.py index 34f7ea34a98..2950fa5c4bd 100644 --- a/pygmt/tests/test_surface.py +++ b/pygmt/tests/test_surface.py @@ -1,7 +1,7 @@ """ Tests for surface. """ -import os +from pathlib import Path import pandas as pd import pytest @@ -142,6 +142,6 @@ def test_surface_with_outgrid_param(data, region, spacing, expected_grid): verbose="e", # Suppress warnings for IEEE 754 rounding ) assert output is None # check that output is None since outgrid is set - assert os.path.exists(path=tmpfile.name) # check that outgrid exists at path + assert Path(tmpfile.name).stat().st_size > 0 # check that outgrid exists with xr.open_dataarray(tmpfile.name) as grid: check_values(grid, expected_grid) diff --git a/pygmt/tests/test_triangulate.py b/pygmt/tests/test_triangulate.py index d2d3b5e7cd1..618aa612f6f 100644 --- a/pygmt/tests/test_triangulate.py +++ b/pygmt/tests/test_triangulate.py @@ -1,7 +1,7 @@ """ Tests for triangulate. """ -import os +from pathlib import Path import numpy as np import pandas as pd @@ -116,7 +116,7 @@ def test_delaunay_triples_outfile(dataframe, expected_dataframe): result = triangulate.delaunay_triples(data=dataframe, outfile=tmpfile.name) assert len(record) == 1 # check that only one warning was raised assert result is None # return value is None - assert os.path.exists(path=tmpfile.name) + assert Path(tmpfile.name).stat().st_size > 0 temp_df = pd.read_csv(filepath_or_buffer=tmpfile.name, sep="\t", header=None) pd.testing.assert_frame_equal(left=temp_df, right=expected_dataframe) @@ -152,7 +152,7 @@ def test_regular_grid_with_outgrid_param(dataframe, expected_grid): data=data, spacing=1, region=[2, 4, 5, 6], outgrid=tmpfile.name ) assert output is None # check that output is None since outgrid is set - assert os.path.exists(path=tmpfile.name) # check that outgrid exists + assert Path(tmpfile.name).stat().st_size > 0 # check that outgrid exists with xr.open_dataarray(tmpfile.name) as grid: assert isinstance(grid, xr.DataArray) assert grid.gmt.registration == 0 # Gridline registration diff --git a/pygmt/tests/test_x2sys_cross.py b/pygmt/tests/test_x2sys_cross.py index ab8c5cff842..34fe668b8cf 100644 --- a/pygmt/tests/test_x2sys_cross.py +++ b/pygmt/tests/test_x2sys_cross.py @@ -3,6 +3,7 @@ Tests for x2sys_cross. """ import os +from pathlib import Path from tempfile import TemporaryDirectory import numpy as np @@ -48,7 +49,7 @@ def test_x2sys_cross_input_file_output_file(mock_x2sys_home): ) assert output is None # check that output is None since outfile is set - assert os.path.exists(path=outfile) # check that outfile exists at path + assert Path(outfile).stat().st_size > 0 # check that outfile exists at path _ = pd.read_csv(outfile, sep="\t", header=2) # ensure ASCII text file loads ok diff --git a/pygmt/tests/test_xyz2grd.py b/pygmt/tests/test_xyz2grd.py index 51747b69c48..ad6c7a0f1f8 100644 --- a/pygmt/tests/test_xyz2grd.py +++ b/pygmt/tests/test_xyz2grd.py @@ -1,7 +1,7 @@ """ Tests for xyz2grd. """ -import os +from pathlib import Path import numpy as np import pytest @@ -63,7 +63,7 @@ def test_xyz2grd_input_array_file_out(ship_data, expected_grid): outgrid=tmpfile.name, ) assert result is None # return value is None - assert os.path.exists(path=tmpfile.name) + assert Path(tmpfile.name).stat().st_size > 0 temp_grid = load_dataarray(tmpfile.name) xr.testing.assert_allclose(a=temp_grid, b=expected_grid)