Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

0.23.0 fails to build due to test failures when no network is available #2368

Closed
sebastic opened this issue Apr 11, 2024 · 3 comments · Fixed by #2369
Closed

0.23.0 fails to build due to test failures when no network is available #2368

sebastic opened this issue Apr 11, 2024 · 3 comments · Fixed by #2369

Comments

@sebastic
Copy link

The Debian package build for 0.23.0 failed due to test failures because there is no network in the build environment.

The tests in question need to be marked accordingly as per this patch:

Description: Mark tests requiring network accordingly.
 Network is not available in the Debian package build environment.
Author: Bas Couwenberg <sebastic@debian.org>

--- a/lib/cartopy/tests/mpl/test_feature_artist.py
+++ b/lib/cartopy/tests/mpl/test_feature_artist.py
@@ -61,6 +61,7 @@ def cached_paths(geom, target_projection
     return geom_cache.get(target_projection, None)
 
 
+@pytest.mark.natural_earth
 @pytest.mark.mpl_image_compare(filename='feature_artist.png')
 def test_feature_artist_draw(feature):
     fig, ax = robinson_map()
@@ -69,6 +70,7 @@ def test_feature_artist_draw(feature):
     return fig
 
 
+@pytest.mark.natural_earth
 @pytest.mark.mpl_image_compare(filename='feature_artist.png')
 def test_feature_artist_draw_facecolor_list(feature):
     fig, ax = robinson_map()
@@ -77,6 +79,7 @@ def test_feature_artist_draw_facecolor_l
     return fig
 
 
+@pytest.mark.natural_earth
 @pytest.mark.mpl_image_compare(filename='feature_artist.png')
 def test_feature_artist_draw_cmap(feature):
     fig, ax = robinson_map()
@@ -87,6 +90,7 @@ def test_feature_artist_draw_cmap(featur
     return fig
 
 
+@pytest.mark.natural_earth
 @pytest.mark.mpl_image_compare(filename='feature_artist.png')
 def test_feature_artist_draw_styled_feature(feature):
     geoms = list(feature.geometries())
@@ -98,6 +102,7 @@ def test_feature_artist_draw_styled_feat
     return fig
 
 
+@pytest.mark.natural_earth
 @pytest.mark.mpl_image_compare(filename='feature_artist.png')
 def test_feature_artist_draw_styler(feature):
     geoms = list(feature.geometries())
--- a/lib/cartopy/tests/mpl/test_features.py
+++ b/lib/cartopy/tests/mpl/test_features.py
@@ -49,6 +49,7 @@ def test_natural_earth_custom():
 
 @pytest.mark.xfail('i386' in sysconfig.get_config_var('MULTIARCH'),
                    reason='Limitations of i386 architecture')
+@pytest.mark.network
 @pytest.mark.skipif(not _HAS_PYKDTREE_OR_SCIPY, reason='pykdtree or scipy is required')
 @pytest.mark.mpl_image_compare(filename='gshhs_coastlines.png', tolerance=0.95)
 def test_gshhs():
--- a/lib/cartopy/tests/mpl/test_gridliner.py
+++ b/lib/cartopy/tests/mpl/test_gridliner.py
@@ -262,6 +262,7 @@ def test_grid_labels_tight():
     return fig
 
 
+@pytest.mark.natural_earth
 @pytest.mark.mpl_image_compare(
     filename='gridliner_constrained_adjust_datalim.png',
     tolerance=grid_label_tol)
@@ -496,6 +497,7 @@ def test_gridliner_count_draws():
         mocked.assert_called_once()
 
 
+@pytest.mark.natural_earth
 @pytest.mark.mpl_image_compare(
     baseline_dir='baseline_images/mpl/test_mpl_integration',
     filename='simple_global.png')
@@ -522,6 +524,7 @@ def test_gridliner_save_tight_bbox():
     fig.savefig(io.BytesIO(), bbox_inches='tight')
 
 
+@pytest.mark.natural_earth
 @pytest.mark.mpl_image_compare(filename='gridliner_labels_title_adjust.png',
                                tolerance=grid_label_tol)
 def test_gridliner_title_adjust():
@greglucas
Copy link
Contributor

I wonder if we could set up an Actions job that disables network access for a single step so we would catch these before they get to you downstream.

@rcomer
Copy link
Member

rcomer commented Apr 12, 2024

I had a go locally with the pytest-socket plugin and it raised for all the tests that are currently missing the markers on main. It seems to be a one-man project, but maybe that doesn't matter so much for something like this that doesn't affect user-facing code?

@greglucas
Copy link
Contributor

@rcomer, I think that would be OK if we just added it to a single CI job like we do for the minimum versions. Another option from a quick glance would be to run the step in a separate network namespace on linux using unshare: https://github.com/orgs/community/discussions/24975

Another thought here is that this would be avoided if we got pytest-vcr implemented as well: #1250 and then wouldn't need network access for any tests.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants