Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
31 changes: 20 additions & 11 deletions pygmt/tests/test_datatypes_dataset.py
Original file line number Diff line number Diff line change
Expand Up @@ -156,16 +156,25 @@ def test_dataset_to_strings_with_none_values():

See the bug report at https://github.com/GenericMappingTools/pygmt/issues/3170.
"""
# Sometimes, the test may fail in CI due to intermittent internet connection issue.
# Catch the FileNotFoundError exception so that we can focus on the bug.
tiles = ["@N30E060.earth_age_01m_g.nc", "@N30E090.earth_age_01m_g.nc"]
paths = which(fname=tiles, download="a")
assert len(paths) == 2
# 'paths' may contain an empty string or not, depending on if the tiles are cached.
if "" not in paths: # Contains two valid paths.
# Delete the cached tiles and try again.
for path in paths:
Path(path).unlink()
with pytest.warns(expected_warning=RuntimeWarning) as record:
paths = which(fname=tiles, download="a")
assert len(record) == 1
try:
paths = which(fname=tiles, download="a")
assert len(paths) == 2
assert "" in paths

# 'paths' may contain an empty string or not, depending on if tiles are cached.
if "" not in paths: # Contains two valid paths.
# Delete the cached tiles and try again.
for path in paths:
Path(path).unlink()
with pytest.warns(expected_warning=RuntimeWarning) as record: # noqa: PT031
try:
paths = which(fname=tiles, download="a")
assert len(record) == 1
assert len(paths) == 2
assert "" in paths
except FileNotFoundError:
pass
except FileNotFoundError:
pass
Loading