From 632e6d2b78d7fcd4d9f119eab94ada13af88b6c2 Mon Sep 17 00:00:00 2001 From: veenstrajelmer Date: Thu, 16 Jan 2025 16:38:02 +0100 Subject: [PATCH] captured other warnings and raised all warnings as errors, firxes #803 --- pyproject.toml | 3 --- tests/test_download.py | 16 ++++++++++++---- 2 files changed, 12 insertions(+), 7 deletions(-) diff --git a/pyproject.toml b/pyproject.toml index 38068953d..6e89d1f01 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -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] diff --git a/tests/test_download.py b/tests/test_download.py index 215407c1e..b2ad03758 100644 --- a/tests/test_download.py +++ b/tests/test_download.py @@ -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) @@ -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)