Skip to content

Allow skipping the testcase that requires network#63

Open
s-t-e-v-e-n-k wants to merge 1 commit intojim-easterbrook:mainfrom
s-t-e-v-e-n-k:skip-network-test
Open

Allow skipping the testcase that requires network#63
s-t-e-v-e-n-k wants to merge 1 commit intojim-easterbrook:mainfrom
s-t-e-v-e-n-k:skip-network-test

Conversation

@s-t-e-v-e-n-k
Copy link

Not all test environments allow internet access, and one of the testcases relies on it by downloading an image over HTTPS. Add a check for a environment variable to skip it.

If 'NONET" is not descriptive enough, I'm happy to update it to 'SKIP_NETWORK' or something else.

Not all test environments allow internet access, and one of the
testcases relies on it by downloading an image over HTTPS. Add a check
for a environment variable to skip it.
@jim-easterbrook
Copy link
Owner

Good idea. I'd really like to automate network detection instead of relying on an environment variable though. I'll investigate what's possible.

@jim-easterbrook
Copy link
Owner

Something like this should do the job:

# Source - https://stackoverflow.com/a/29854274
# Posted by Ivelin, modified by community. See post 'Timeline' for change history
# Retrieved 2026-03-16, License - CC BY-SA 4.0

import http.client

def have_internet():
    conn = http.client.HTTPSConnection("8.8.8.8", timeout=5)
    try:
        conn.request("HEAD", "/")
        return True
    except Exception:
        return False
    finally:
        conn.close()

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants