mirror of
https://github.com/kennethreitz/pipenv.git
synced 2026-06-05 06:46:15 +00:00
Fix internet connectivity test
Signed-off-by: Dan Ryan <dan@danryan.co>
This commit is contained in:
+17
-1
@@ -2,7 +2,23 @@
|
||||
addopts = -ra -n auto
|
||||
testpaths = tests
|
||||
; Add vendor and patched in addition to the default list of ignored dirs
|
||||
norecursedirs = .* build dist CVS _darcs {arch} *.egg vendor patched news tasks docs tests/test_artifacts
|
||||
; Additionally, ignore tasks, news, test subdirectories and peeps directory
|
||||
norecursedirs =
|
||||
.* build
|
||||
dist
|
||||
CVS
|
||||
_darcs
|
||||
{arch}
|
||||
*.egg
|
||||
vendor
|
||||
patched
|
||||
news
|
||||
tasks
|
||||
docs
|
||||
tests/test_artifacts
|
||||
tests/pytest-pypi
|
||||
tests/pypi
|
||||
peeps
|
||||
filterwarnings =
|
||||
ignore::DeprecationWarning
|
||||
ignore::PendingDeprecationWarning
|
||||
|
||||
@@ -23,16 +23,24 @@ warnings.simplefilter("default", category=ResourceWarning)
|
||||
HAS_WARNED_GITHUB = False
|
||||
|
||||
|
||||
def try_internet(url="http://httpbin.org/ip", timeout=1.5):
|
||||
resp = requests.get(url, timeout=timeout)
|
||||
resp.raise_for_status()
|
||||
|
||||
|
||||
def check_internet():
|
||||
try:
|
||||
# Kenneth represents the Internet LGTM.
|
||||
resp = requests.get('http://httpbin.org/ip', timeout=1.0)
|
||||
resp.raise_for_status()
|
||||
except Exception:
|
||||
warnings.warn('Cannot connect to HTTPBin...', RuntimeWarning)
|
||||
warnings.warn('Will skip tests requiring Internet', RuntimeWarning)
|
||||
return False
|
||||
return True
|
||||
has_internet = False
|
||||
for url in ("http://httpbin.org/ip", "http://clients3.google.com/generate_204"):
|
||||
try:
|
||||
try_internet(url)
|
||||
except Exception:
|
||||
warnings.warn(
|
||||
"Failed connecting to internet: {0}".format(url), RuntimeWarning
|
||||
)
|
||||
else:
|
||||
has_internet = True
|
||||
break
|
||||
return has_internet
|
||||
|
||||
|
||||
def check_github_ssh():
|
||||
|
||||
Reference in New Issue
Block a user