Skip to content

Commit

Permalink
captured other warnings and raised all warnings as errors, firxes #803
Browse files Browse the repository at this point in the history
  • Loading branch information
veenstrajelmer committed Jan 16, 2025
1 parent 33fd84c commit 632e6d2
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 7 deletions.
3 changes: 0 additions & 3 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -113,9 +113,6 @@ markers = [
]
filterwarnings = [
"error",
#"ignore::UserWarning",
# note the use of single quote below to denote "raw" strings in TOML
#'ignore:function ham\(\) is deprecated:DeprecationWarning',
]

[tool.flake8]
Expand Down
16 changes: 12 additions & 4 deletions tests/test_download.py
Original file line number Diff line number Diff line change
Expand Up @@ -130,18 +130,22 @@ def test_cds_credentials_oldurl_incorrectkey_rcfile():
cds_apikey_temp = "INCORRECT-APIKEY"
cds_set_credentials_rcfile(cds_url_temp, cds_apikey_temp)
with pytest.raises(ValueError) as e:
cds_credentials()
with pytest.warns(UserWarning) as w:
cds_credentials()
assert "Old CDS URL found" in str(e.value)
assert "The CDS/ECMWF apikey file (~/.cdsapirc) was deleted" in str(e.value)
assert "404 Client Error: Not Found for url:" in str(w[0].message)

# test
cds_url_temp = "https://cds-beta.climate.copernicus.eu/api"
cds_apikey_temp = "INCORRECT-APIKEY"
cds_set_credentials_rcfile(cds_url_temp, cds_apikey_temp)
with pytest.raises(ValueError) as e:
cds_credentials()
with pytest.warns(UserWarning) as w:
cds_credentials()
assert "Old CDS URL found" in str(e.value)
assert "The CDS/ECMWF apikey file (~/.cdsapirc) was deleted" in str(e.value)
assert "certificate verify failed" in str(w[0].message)

# restore credentials file/envvars
set_cds_credentials_ifnot_none(cds_url, cds_apikey)
Expand All @@ -158,17 +162,21 @@ def test_cds_credentials_oldurl_incorrectkey_envvars():
os.environ["CDSAPI_URL"] = "https://cds.climate.copernicus.eu/api/v2"
os.environ["CDSAPI_KEY"] = "INCORRECT-APIKEY"
with pytest.raises(ValueError) as e:
cds_credentials()
with pytest.warns(UserWarning) as w:
cds_credentials()
assert "Old CDS URL found" in str(e.value)
assert "The CDS/ECMWF apikey file (~/.cdsapirc) was deleted" in str(e.value)
assert "404 Client Error: Not Found for url:" in str(w[0].message)

# test
os.environ["CDSAPI_URL"] = "https://cds-beta.climate.copernicus.eu/api"
os.environ["CDSAPI_KEY"] = "INCORRECT-APIKEY"
with pytest.raises(ValueError) as e:
cds_credentials()
with pytest.warns(UserWarning) as w:
cds_credentials()
assert "Old CDS URL found" in str(e.value)
assert "The CDS/ECMWF apikey file (~/.cdsapirc) was deleted" in str(e.value)
assert "certificate verify failed" in str(w[0].message)

# restore credentials file/envvars
set_cds_credentials_ifnot_none(cds_url, cds_apikey)
Expand Down

0 comments on commit 632e6d2

Please sign in to comment.