From fd60ed4ae860d9dce41c20988d93bf4478b13620 Mon Sep 17 00:00:00 2001 From: Charles Turner Date: Mon, 3 Feb 2025 09:25:27 +0800 Subject: [PATCH] Separate out expected failing tests from expected passing tests - the pytest.mark.flaky() decorator seems to work fine on my local machine but is causing CI issues - not quite sure why --- tests/test_tutorial.py | 20 +++++++++++++++++--- 1 file changed, 17 insertions(+), 3 deletions(-) diff --git a/tests/test_tutorial.py b/tests/test_tutorial.py index 4bfa683e..91fbe25a 100644 --- a/tests/test_tutorial.py +++ b/tests/test_tutorial.py @@ -4,9 +4,7 @@ import intake_esm from intake_esm.tutorial import DEFAULT_CATALOGS -tutorial_cats = list(zip(DEFAULT_CATALOGS.keys(), DEFAULT_CATALOGS.values())) + [ - pytest.param('bad_key', 'bad_url', marks=pytest.mark.xfail) -] +tutorial_cats = list(zip(DEFAULT_CATALOGS.keys(), DEFAULT_CATALOGS.values())) @pytest.mark.parametrize('name,url', tutorial_cats) @@ -17,6 +15,13 @@ def test_get_url(name, url): assert cat_url == url +@pytest.mark.xfail +def test_get_url_xfail(): + cat_url = intake_esm.tutorial.get_url('bad_key') + assert isinstance(cat_url, str) + assert 'bad_url' == 'bad_url' + + @pytest.mark.network @pytest.mark.parametrize('name,url', tutorial_cats) @pytest.mark.flaky(max_runs=3, min_passes=1) # Cold start related failures @@ -27,6 +32,15 @@ def test_open_from_url(name, url): assert cat == intake.open_esm_datastore(url) +@pytest.mark.network +@pytest.mark.xfail +def test_open_from_url_xfail(): + cat_url = intake_esm.tutorial.get_url('bad_url') + cat = intake.open_esm_datastore(cat_url) + assert isinstance(cat.esmcat, intake_esm.cat.ESMCatalogModel) + assert cat == intake.open_esm_datastore('bad_url') + + def test_get_available_cats(): cats = intake_esm.tutorial.get_available_cats() assert cats == list(DEFAULT_CATALOGS.keys())